From: Junio C Hamano Date: Wed, 30 Nov 2005 08:37:46 GMT Subject: Re: git-name-rev off-by-one bug Message-ID: <7vek4ywmxx.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <7voe43iyyu.fsf@assigned-by-dhcp.cox.net> Junio C Hamano writes: > On a related topic of removing unwanted paths, earlier I said > 2-way is used to make sure "git checkout" takes your changes > with you when you switch branches. As a natural consequence of > this, if you do not have any local changes, "git checkout" > without "-f" does the right thing -- it removes unwanted paths > that existed in the original branch but not in the branch you > are switching to. Here is an unsolicited advice ("tip of the day"). I was on a branch which had some local "throwaway" changes, and I wanted to switch back to the master branch. To be honest, I even forgot I had local changes there. So I ran "git checkout", and here is what happened. junio@siamese:~/git$ git checkout master fatal: Entry 'Documentat...' not uptodate. Cannot merge. The easiest is "git checkout -f master" at this point, but I usually do not do that. If that entry "git checkout" complains about is something that is not in the master branch and I have throwaway changes, "git checkout -f master" would leave that file with throwaway changes behind. So I did this first: junio@siamese:~/git$ git reset --hard This would sync my working tree to the current branch. Then junio@siamese:~/git$ git checkout master would switch branches properly, removing that new file that should not exist in the working tree.