Re: [PATCH] checkout -d: explicitly detach HEAD even when switching to the tip of a branch
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Apr 4, 2007, 01:55 UTC
- Message-ID
- <Pine.LNX.4.64.0704031850240.6730@woody.linux-foundation.org>
- 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 <some-random-head>
it would have screwed up the current branch horribly.
With detached heads, I don't think it's needed.
Linus