Re: Git branches - confusing behavior

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

 




Jakub Narebski wrote:
> Dima Kagan <dima.kagan@xxxxxxxxx> writes:
> 
>> 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")
> 
> And now you have 'somefile' in the working arew, which state isn't
> saved anywhere git knows of.
>  
>> This is what I expect of course. However, when I execute 'git checkout
>> master', I get:
>> M       somefile
>> Switched to branch "master"
> 
> Git tries hard to preserve your modifications.  If you don't want to
> commit changes to test_branch, you can use git-stash to stash them
> away.
> 
> Note that the above is possible only in the trivial merge case.
> Otherwise you would need to use "git checkout -m" (to merge), or
> "git checkout -f" (to force checkout, possibly losing changes).
> 

So if I am working on more than one branch at a time I need to commit my changes every time before I do
'git checkout <branch>'?

>> 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?
> 
> This is normal, and wanted, behavior.
> 

That's a subjective point of view :) I'm coming from the SVN world and uncommitted changes on one branch don't affect other branches. Is there a way I can achieve this behavior with git?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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