git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git checkout: difference in behavior and what is in the documentation
@ 2010-07-02  5:30 Sabyasachi Ruj
  2010-07-02  6:09 ` Markus Heidelberg
  0 siblings, 1 reply; 3+ messages in thread
From: Sabyasachi Ruj @ 2010-07-02  5:30 UTC (permalink / raw)
  To: git

I've asked the question in detail in Stack Overflow:

http://stackoverflow.com/questions/3163325/confusion-about-git-checkout

Even if there is no bug in the git behavior, I think the documentation
should be more clear.

-- 
Sabyasachi

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

* Re: Git checkout: difference in behavior and what is in the documentation
  2010-07-02  5:30 Git checkout: difference in behavior and what is in the documentation Sabyasachi Ruj
@ 2010-07-02  6:09 ` Markus Heidelberg
  2010-07-02  8:29   ` Chris.Cheney
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Heidelberg @ 2010-07-02  6:09 UTC (permalink / raw)
  To: Sabyasachi Ruj; +Cc: git

Sabyasachi Ruj, 2010-07-02 07:30:
> I've asked the question in detail in Stack Overflow:
> 
> http://stackoverflow.com/questions/3163325/confusion-about-git-checkout

You should rather post the question and not only the link. Here is the
relevant part:

> I am confused about a behavior of git checkout. The documentation of git
> checkout says:
> 
> --merge 
> When switching branches, if you have local modifications to one or
> more files that are different between the current branch and the
> branch to which you are switching, the command refuses to switch
> branches in order to preserve your modifications in context. However,
> with this option, a three-way merge between the current branch, your
> working tree contents, and the new branch is done, and you will be on
> the new branch.
> 
> But, I have done a small test which is not behaving as said in the bold
> part. That is:
> 1. I create a git repo
> 2. create a directory and a file with some conent and commit it in
>    master branch.
> 3. Create another branch "testbranch"
> 4. change the content of the file in master. But did not commit.
> 5. switched to "testbranch". 
> 6. Now the changed and uncommitted changes from master branch come to
>    testbranch!
> 
> Wasn't it supposed to fail, if I have some local changes and wanted to
> switch to a branch?

'master' and 'testbranch' are the same, so there are no "files that are
different between the current branch and the branch to which you are
switching", so git doesn't have to fail.

> Even if there is no bug in the git behavior, I think the documentation
> should be more clear.

I think it's quite clear.

Markus

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

* Re: Git checkout: difference in behavior and what is in the documentation
  2010-07-02  6:09 ` Markus Heidelberg
@ 2010-07-02  8:29   ` Chris.Cheney
  0 siblings, 0 replies; 3+ messages in thread
From: Chris.Cheney @ 2010-07-02  8:29 UTC (permalink / raw)
  To: git

Markus Heidelberg <markus.heidelberg@web.de> wrote in 
news:201007020809.17551.markus.heidelberg@web.de:

> Sabyasachi Ruj, 2010-07-02 07:30:
>> I've asked the question in detail in Stack Overflow:
>> 
>> http://stackoverflow.com/questions/3163325/confusion-about-git-checkout
> 
> You should rather post the question and not only the link. Here is the
> relevant part:
> 
>> I am confused about a behavior of git checkout. The documentation of git
>> checkout says:
>> 
>> --merge 
>> When switching branches, if you have local modifications to one or
>> more files that are different between the current branch and the
>> branch to which you are switching, the command refuses to switch
>> branches in order to preserve your modifications in context. However,
>> with this option, a three-way merge between the current branch, your
>> working tree contents, and the new branch is done, and you will be on
>> the new branch.
>> 
>> But, I have done a small test which is not behaving as said in the bold
>> part. That is:
>> 1. I create a git repo
>> 2. create a directory and a file with some conent and commit it in
>>    master branch.
>> 3. Create another branch "testbranch"
>> 4. change the content of the file in master. But did not commit.
>> 5. switched to "testbranch". 
>> 6. Now the changed and uncommitted changes from master branch come to
>>    testbranch!
>> 
>> Wasn't it supposed to fail, if I have some local changes and wanted to
>> switch to a branch?
> 
> 'master' and 'testbranch' are the same, 

Rather, 'master' and 'testbranch' are the names of different branches, but 
they identify the same commit at that time.

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

end of thread, other threads:[~2010-07-02  8:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-02  5:30 Git checkout: difference in behavior and what is in the documentation Sabyasachi Ruj
2010-07-02  6:09 ` Markus Heidelberg
2010-07-02  8:29   ` Chris.Cheney

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).