Re: question concerning branches
flat view
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:17
ib@wupperonline.de (Ingo Brueckl) writes:
I'm a git novice and have a comprehension question concerning branches. Within a git repository, I do: git branch test git checkout test # edit foo.bar git checkout master I'd expect that master is in the exactly same unchanged state it was at branching time, but what a surprise, foo.bar is modified here, too!
No. Local modification that are not committed do not belong to any
branch. Rather it belongs to your work tree and the index, and follow you
when you switch branches.
This is one of the most useful features. For example, it is an essential
part of supporting the workflow described here:
http://gitster.livejournal.com/25892.html
On the other hand, there are cases that you do not want to see your local
changes to foo.bar appear when you switch back to master, and the most
obvious case is "I started working on something, and I used a separate
branch 'test' because the change will be involved. I am in the middle of
the work, the changes so far I made to foo.bar is far from ready, but I
have to handle emergency fix on the master branch". For that kind of
situation, you can use "git stash", like:
http://gitster.livejournal.com/29577.html