Re: Git branches - confusing behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 11, 3:58 am, mitya <dima.ka...@xxxxxxxxx> wrote:
> I started with the following steps:
> 
> > git-svn clonehttp://svn.test.org/test/trunk
> > cd trunk
> > git branch test_branch
> > git checkout test_branch
> > vi somefile
> 
> However, when I execute 'git checkout master', I get:
> M       somefile
> Switched to branch "master"
> 
> Basically I see that the same file I edited on the 'test_branch'
> branch appears to be modified on the 'master' branch as well. 

I was also confused by this behavior.  I think this is a documentation issue.  In the "man" page for "git-checkout", the "Description" section says:

"...this command switches branches by updating the index and working tree to reflect the specified branch...".

This led me to believe that all files in the working tree would be updated to match the last commit in the specified branch.  The "Description" section doesn't mention any exceptions, such as files that have been modified but not committed in the current branch.  

There are some clues that this is the intended behavior in the descriptions of the "-f" and "-m" options, and in the "After working in the wrong branch..." example.  But it was not clear to me from reading the "man" page (and the "gittutorial" and the "Git User's Guide") that this behavior was correct and intended. 

I think it would be helpful in the "Description" section of the "man" page to elaborate on how git updates the working tree to reflect the specified branch.  This could include documenting the default handling of files that have been modified in the current branch.  A rationale for the behavior would also be helpful.  This might have prevented my confusion when first encountering this issue.
  
--
Matt Seitz
Manager, File System Virtualization
Cisco Systems, Inc.
.:|:.:|:. 
��.n��������+%������w��{.n��������n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�m


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux