{"thread":{"id":"24260","subject":"Git checkout: difference in behavior and what is in the documentation","startedAt":"2010-07-02T05:30:59Z","lastAt":"2010-07-02T08:29:28Z","messageCount":3,"participants":["Sabyasachi Ruj","Markus Heidelberg","Chris.Cheney"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144663","messageId":"AANLkTil4LcA0F5FEeoKOnR7Ko_gEpMHD_HCi3FPTG55D@mail.gmail.com","threadId":"24260","inReplyTo":null,"subject":"Git checkout: difference in behavior and what is in the documentation","fromName":"Sabyasachi Ruj","fromEmail":"ruj.sabya@gmail.com","sentAt":"2010-07-02T05:30:59Z","receivedAt":"2010-07-02T05:30:59Z","isPatch":false,"sender":{"key":"ruj.sabya@gmail.com","avatar":"https://gravatar.com/avatar/d6ca171222ef790f70142465c2987175fff15e3039b0bdd9e5f382dab051eadf?d=mp&s=160"},"body":"I've asked the question in detail in Stack Overflow:\n\nhttp://stackoverflow.com/questions/3163325/confusion-about-git-checkout\n\nEven if there is no bug in the git behavior, I think the documentation\nshould be more clear.\n\n-- \nSabyasachi\n"},{"id":"144665","messageId":"201007020809.17551.markus.heidelberg@web.de","threadId":"24260","inReplyTo":"AANLkTil4LcA0F5FEeoKOnR7Ko_gEpMHD_HCi3FPTG55D@mail.gmail.com","subject":"Re: Git checkout: difference in behavior and what is in the documentation","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2010-07-02T06:09:17Z","receivedAt":"2010-07-02T06:09:17Z","isPatch":false,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Sabyasachi Ruj, 2010-07-02 07:30:\n> I've asked the question in detail in Stack Overflow:\n> \n> http://stackoverflow.com/questions/3163325/confusion-about-git-checkout\n\nYou should rather post the question and not only the link. Here is the\nrelevant part:\n\n> I am confused about a behavior of git checkout. The documentation of git\n> checkout says:\n> \n> --merge \n> When switching branches, if you have local modifications to one or\n> more files that are different between the current branch and the\n> branch to which you are switching, the command refuses to switch\n> branches in order to preserve your modifications in context. However,\n> with this option, a three-way merge between the current branch, your\n> working tree contents, and the new branch is done, and you will be on\n> the new branch.\n> \n> But, I have done a small test which is not behaving as said in the bold\n> part. That is:\n> 1. I create a git repo\n> 2. create a directory and a file with some conent and commit it in\n>    master branch.\n> 3. Create another branch \"testbranch\"\n> 4. change the content of the file in master. But did not commit.\n> 5. switched to \"testbranch\". \n> 6. Now the changed and uncommitted changes from master branch come to\n>    testbranch!\n> \n> Wasn't it supposed to fail, if I have some local changes and wanted to\n> switch to a branch?\n\n'master' and 'testbranch' are the same, so there are no \"files that are\ndifferent between the current branch and the branch to which you are\nswitching\", so git doesn't have to fail.\n\n> Even if there is no bug in the git behavior, I think the documentation\n> should be more clear.\n\nI think it's quite clear.\n\nMarkus\n"},{"id":"144672","messageId":"Xns9DA96096F7CEChrisCheneytesconet@80.91.229.10","threadId":"24260","inReplyTo":"201007020809.17551.markus.heidelberg@web.de","subject":"Re: Git checkout: difference in behavior and what is in the documentation","fromName":"Chris.Cheney","fromEmail":"chris.cheney.nospam@tesco.net","sentAt":"2010-07-02T08:29:28Z","receivedAt":"2010-07-02T08:29:28Z","isPatch":false,"sender":{"key":"chris.cheney.nospam@tesco.net","avatar":null},"body":"Markus Heidelberg <markus.heidelberg@web.de> wrote in \nnews:201007020809.17551.markus.heidelberg@web.de:\n\n> Sabyasachi Ruj, 2010-07-02 07:30:\n>> I've asked the question in detail in Stack Overflow:\n>> \n>> http://stackoverflow.com/questions/3163325/confusion-about-git-checkout\n> \n> You should rather post the question and not only the link. Here is the\n> relevant part:\n> \n>> I am confused about a behavior of git checkout. The documentation of git\n>> checkout says:\n>> \n>> --merge \n>> When switching branches, if you have local modifications to one or\n>> more files that are different between the current branch and the\n>> branch to which you are switching, the command refuses to switch\n>> branches in order to preserve your modifications in context. However,\n>> with this option, a three-way merge between the current branch, your\n>> working tree contents, and the new branch is done, and you will be on\n>> the new branch.\n>> \n>> But, I have done a small test which is not behaving as said in the bold\n>> part. That is:\n>> 1. I create a git repo\n>> 2. create a directory and a file with some conent and commit it in\n>>    master branch.\n>> 3. Create another branch \"testbranch\"\n>> 4. change the content of the file in master. But did not commit.\n>> 5. switched to \"testbranch\". \n>> 6. Now the changed and uncommitted changes from master branch come to\n>>    testbranch!\n>> \n>> Wasn't it supposed to fail, if I have some local changes and wanted to\n>> switch to a branch?\n> \n> 'master' and 'testbranch' are the same, \n\nRather, 'master' and 'testbranch' are the names of different branches, but \nthey identify the same commit at that time.\n"}]}