Re: question concerning branches

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

 



ib@xxxxxxxxxxxxxxx (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
--
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]