git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git branches - confusing behavior
@ 2008-05-11 11:31 Dima Kagan
  2008-05-11 11:42 ` Jakub Narebski
  0 siblings, 1 reply; 20+ messages in thread
From: Dima Kagan @ 2008-05-11 11:31 UTC (permalink / raw)
  To: git

Hi,

I'm currently evaluating git for doing some local work without
depending on the main subversion server. I started with the following
steps:

> git-svn clone http://svn.test.org/test/trunk
> cd trunk
> git branch test_branch
> git checkout test_branch
> vi somefile

Now, when I run 'git status' I get:
# On branch test_branch
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   somefile
#
no changes added to commit (use "git add" and/or "git commit -a")

This is what I expect of course. However, when I execute 'git checkout
master', I get:
M       somefile
Switched to branch "master"

And after running 'git status' on master I get:
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   somefile
#
no changes added to commit (use "git add" and/or "git commit -a")

Basically I see that the same file I edited on the 'test_branch'
branch appears to be modified on the 'master' branch as well. This
behavior is unwanted, of course.

Can someone please tell me, what am doing wrong? Or is this git's
normal behavior?

Thanks in advance! 

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: Git branches - confusing behavior
@ 2008-06-30  7:23 Matt Seitz (matseitz)
  0 siblings, 0 replies; 20+ messages in thread
From: Matt Seitz (matseitz) @ 2008-06-30  7:23 UTC (permalink / raw)
  To: git; +Cc: dima.kagan

On May 11, 3:58 am, mitya <dima.ka...@gmail.com> 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.
.:|:.:|:. 

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

end of thread, other threads:[~2008-06-30  7:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-11 11:31 Git branches - confusing behavior Dima Kagan
2008-05-11 11:42 ` Jakub Narebski
2008-05-11 11:58   ` Dima Kagan
2008-05-11 12:06     ` David Symonds
2008-05-11 12:11       ` Dima Kagan
2008-05-11 12:13         ` David Symonds
2008-05-11 12:17           ` Dima Kagan
2008-05-11 12:20     ` Steve Frécinaux
     [not found]     ` <f35478f50805110513h15aa462bs9ee35ed4738d3009@mail.gmail.com>
2008-05-11 12:21       ` Dima Kagan
2008-05-11 13:40     ` Jakub Narebski
2008-05-11 12:33   ` Dima Kagan
2008-05-11 12:57     ` Björn Steinbrink
2008-05-11 13:04       ` Dima Kagan
2008-05-11 13:27         ` Björn Steinbrink
2008-05-11 13:39           ` Dima Kagan
     [not found]             ` <4826F72D.2070205-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-05-11 15:25               ` Patrick Aljord
2008-05-11 15:39             ` Teemu Likonen
2008-05-12  7:49             ` Miles Bader
2008-05-11 14:03         ` Theodore Tso
  -- strict thread matches above, loose matches on Subject: below --
2008-06-30  7:23 Matt Seitz (matseitz)

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