From: Linus Torvalds Date: Wed, 04 Apr 2007 01:55:03 GMT Subject: Re: [PATCH] checkout -d: explicitly detach HEAD even when switching to the tip of a branch Message-ID: In-Reply-To: <7vtzvxt2v3.fsf@assigned-by-dhcp.cox.net> On Tue, 3 Apr 2007, Junio C Hamano wrote: > > Could anybody remind me why we have the "new != old" check here? Afaik, it's just so that you can do git checkout -f without having it complain. And I think it just comes from the earlier: [ -z "$new" ] && new=$old && new_name="$old_name" that we did - ie without that it would incorrectly just overwrite the current working tree with the new commit, but not actually do the "git reset" part. So without that check, the way things used to work (*before* detached heads), if you were to have done git checkout it would have screwed up the current branch horribly. With detached heads, I don't think it's needed. Linus