{"thread":{"id":"11605","subject":"git-checkout question","startedAt":"2008-01-13T14:21:40Z","lastAt":"2008-01-13T15:12:02Z","messageCount":3,"participants":["David J. Neu","Steffen Prohaska"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"65242","messageId":"20080113142140.GB10426@bach.davidneu.local","threadId":"11605","inReplyTo":null,"subject":"git-checkout question","fromName":"David J. Neu","fromEmail":"davidjneu@gmail.com","sentAt":"2008-01-13T14:21:40Z","receivedAt":"2008-01-13T14:21:40Z","isPatch":false,"sender":{"key":"davidjneu@gmail.com","avatar":null},"body":"Hi, \n\nI was wondering if someone could explain the following behavior.\n\n1. create and switch to branch off master\n2. edit a file in the branch\n3. checkout master without committing changes in the branch\n4. the changes in the branch are automatically applied in working tree \n   in master\n\nI wasn't expecting the changes in the branch to be automatically\nmoved to master.  Had I committed while in the branch this doesn't\nhappen.  I'm using git version 1.5.3, the details are below.\n\nMany thanks!\n\nCheers,\nDavid\n\n[/tmp] mkdir git-test\n[/tmp] cd git-test\n[/tmp/git-test] git-init \nInitialized empty Git repository in .git/\n[/tmp/git-test] # create hello.py\n[/tmp/git-test] git-add hello.py \n[/tmp/git-test] git-commit   \nCreated initial commit 58282ee: Initial commit of git-test.\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 hello.py\n[/tmp/git-test] cat hello.py \nprint \"hello from master.\"\n[/tmp/git-test] git-checkout -b test-branch\nSwitched to a new branch \"test-branch\"\n[/tmp/git-test] # modify hello.py\n[/tmp/git-test] cat hello.py \nprint \"hello from test-branch.\"\n[/tmp/git-test] git-checkout master\nM       hello.py\nSwitched to branch \"master\"\n[/tmp/git-test] cat hello.py \nprint \"hello from test-branch.\"\n[/tmp/git-test] # hmmm?\n"},{"id":"65243","messageId":"AF05EA04-C41A-4964-B225-E3A427D32E33@zib.de","threadId":"11605","inReplyTo":"20080113142140.GB10426@bach.davidneu.local","subject":"Re: git-checkout question","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-01-13T14:31:19Z","receivedAt":"2008-01-13T14:31:19Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jan 13, 2008, at 3:21 PM, David J. Neu wrote:\n\n> I was wondering if someone could explain the following behavior.\n>\n> 1. create and switch to branch off master\n> 2. edit a file in the branch\n> 3. checkout master without committing changes in the branch\n> 4. the changes in the branch are automatically applied in working tree\n>    in master\n>\n> I wasn't expecting the changes in the branch to be automatically\n> moved to master.  Had I committed while in the branch this doesn't\n> happen.\n\nThis already is the explanation.  You did not commit.  Therefore,\nthe changes are not in the branch but still in your work tree.\nThey are on neither branch; they are _only_ in your work tree.\nIf you switch the branch the changes will stay in the work tree.\nThey always stayed in the same place: your work tree.\n\n\tSteffen\n"},{"id":"65246","messageId":"20080113151202.GC10426@bach.davidneu.local","threadId":"11605","inReplyTo":"AF05EA04-C41A-4964-B225-E3A427D32E33@zib.de","subject":"Re: git-checkout question","fromName":"David J. Neu","fromEmail":"davidjneu@gmail.com","sentAt":"2008-01-13T15:12:02Z","receivedAt":"2008-01-13T15:12:02Z","isPatch":false,"sender":{"key":"davidjneu@gmail.com","avatar":null},"body":"\nOn Sun, Jan 13, 2008 at 03:31:19PM +0100, Steffen Prohaska wrote:\n> \n> On Jan 13, 2008, at 3:21 PM, David J. Neu wrote:\n> \n> >I was wondering if someone could explain the following behavior.\n> >\n> >1. create and switch to branch off master\n> >2. edit a file in the branch\n> >3. checkout master without committing changes in the branch\n> >4. the changes in the branch are automatically applied in working tree\n> >   in master\n> >\n> >I wasn't expecting the changes in the branch to be automatically\n> >moved to master.  Had I committed while in the branch this doesn't\n> >happen.\n> \n> This already is the explanation.  You did not commit.  Therefore,\n> the changes are not in the branch but still in your work tree.\n> They are on neither branch; they are _only_ in your work tree.\n> If you switch the branch the changes will stay in the work tree.\n> They always stayed in the same place: your work tree.\n> \n> \tSteffen\n> \n\nAhh, got it - thanks!\n"}]}