git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-checkout question
@ 2008-01-13 14:21 David J. Neu
  2008-01-13 14:31 ` Steffen Prohaska
  0 siblings, 1 reply; 3+ messages in thread
From: David J. Neu @ 2008-01-13 14:21 UTC (permalink / raw)
  To: git

Hi, 

I was wondering if someone could explain the following behavior.

1. create and switch to branch off master
2. edit a file in the branch
3. checkout master without committing changes in the branch
4. the changes in the branch are automatically applied in working tree 
   in master

I wasn't expecting the changes in the branch to be automatically
moved to master.  Had I committed while in the branch this doesn't
happen.  I'm using git version 1.5.3, the details are below.

Many thanks!

Cheers,
David

[/tmp] mkdir git-test
[/tmp] cd git-test
[/tmp/git-test] git-init 
Initialized empty Git repository in .git/
[/tmp/git-test] # create hello.py
[/tmp/git-test] git-add hello.py 
[/tmp/git-test] git-commit   
Created initial commit 58282ee: Initial commit of git-test.
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 hello.py
[/tmp/git-test] cat hello.py 
print "hello from master."
[/tmp/git-test] git-checkout -b test-branch
Switched to a new branch "test-branch"
[/tmp/git-test] # modify hello.py
[/tmp/git-test] cat hello.py 
print "hello from test-branch."
[/tmp/git-test] git-checkout master
M       hello.py
Switched to branch "master"
[/tmp/git-test] cat hello.py 
print "hello from test-branch."
[/tmp/git-test] # hmmm?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git-checkout question
  2008-01-13 14:21 git-checkout question David J. Neu
@ 2008-01-13 14:31 ` Steffen Prohaska
  2008-01-13 15:12   ` David J. Neu
  0 siblings, 1 reply; 3+ messages in thread
From: Steffen Prohaska @ 2008-01-13 14:31 UTC (permalink / raw)
  To: djneu; +Cc: git


On Jan 13, 2008, at 3:21 PM, David J. Neu wrote:

> I was wondering if someone could explain the following behavior.
>
> 1. create and switch to branch off master
> 2. edit a file in the branch
> 3. checkout master without committing changes in the branch
> 4. the changes in the branch are automatically applied in working tree
>    in master
>
> I wasn't expecting the changes in the branch to be automatically
> moved to master.  Had I committed while in the branch this doesn't
> happen.

This already is the explanation.  You did not commit.  Therefore,
the changes are not in the branch but still in your work tree.
They are on neither branch; they are _only_ in your work tree.
If you switch the branch the changes will stay in the work tree.
They always stayed in the same place: your work tree.

	Steffen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git-checkout question
  2008-01-13 14:31 ` Steffen Prohaska
@ 2008-01-13 15:12   ` David J. Neu
  0 siblings, 0 replies; 3+ messages in thread
From: David J. Neu @ 2008-01-13 15:12 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: git


On Sun, Jan 13, 2008 at 03:31:19PM +0100, Steffen Prohaska wrote:
> 
> On Jan 13, 2008, at 3:21 PM, David J. Neu wrote:
> 
> >I was wondering if someone could explain the following behavior.
> >
> >1. create and switch to branch off master
> >2. edit a file in the branch
> >3. checkout master without committing changes in the branch
> >4. the changes in the branch are automatically applied in working tree
> >   in master
> >
> >I wasn't expecting the changes in the branch to be automatically
> >moved to master.  Had I committed while in the branch this doesn't
> >happen.
> 
> This already is the explanation.  You did not commit.  Therefore,
> the changes are not in the branch but still in your work tree.
> They are on neither branch; they are _only_ in your work tree.
> If you switch the branch the changes will stay in the work tree.
> They always stayed in the same place: your work tree.
> 
> 	Steffen
> 

Ahh, got it - thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-13 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-13 14:21 git-checkout question David J. Neu
2008-01-13 14:31 ` Steffen Prohaska
2008-01-13 15:12   ` David J. Neu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).