From: Jeff King Date: Mon, 11 Jun 2012 18:55:07 GMT Subject: Re: Help understanding git checkout behavior Message-ID: <20120611185507.GF20134@sigill.intra.peff.net> In-Reply-To: On Mon, Jun 11, 2012 at 02:34:01PM -0400, Leila wrote: > When you create a branch, it will contain everything committed on the > branch you created it from at that given point. So if you commit more > things on the master branch like you have done (after creating b), > then switch to branch b, they won't appear. This is the correct > behavior. Does that answer your question? No, the problem is more subtle: > >> smooke  teste $ git rm something > >> rm 'something' > >> smooke  teste $ mkdir something > >> smooke  teste $ cd something/ > >> smooke  something $ touch f1 > >> smooke  something $ echo c > f1 > >> smooke  something $ cd .. > >> smooke  teste $ git add something/f1 > >> smooke  teste $ git checkout b > >> Switched to branch 'b' > >> smooke  teste $ ls > >> f We have lost "something/f1" during the switch, which was not committed anywhere. This is presumably an error because we see that "something" used to be tracked, and now we are tracking something different there. If we had put some new content into the file "something", git would rightfully complain with: $ git checkout b error: Your local changes to the following files would be overwritten by checkout: something Please, commit your changes or stash them before you can switch branches. Aborting But it misses the case when "something" switches from a file into a directory, which is probably a bug. -Peff