Subject: Re: disallowing push to currently checked-out branch

From: Junio C Hamano <[email-masked]>
Date: Mon, 16 Feb 2009 16:57:55 -0800

Sergio Callegari <[email-masked]> writes:

> Johannes Schindelin wrote:
>> Of course, you can go on and on and on with the detached HEAD ide,
>> but so far you haven't convinced me that this is a sensible thing to
>> do.
>>
> I will not... it's time to sleep where I am! And I am just a user of
> git and you are a developer, which makes me think that you might know
> much better.
> But the exchange was insightful, thanks.
>
> Rather, I'll turn again the question...
>
> Let us assume that I am working on branch B and that my worktree is
> based on commit XYZ. Let's also assume that someone pushes behind my
> shoulders and moves the tip of B (or even deletes B alltogether)
> either in one or in multiple pushes.  Is there an easy way so that I
> can now find out at what commit (XYZ) I was before the push(es)?

I am afraind that you are going on-and-on-and-on Dscho warned you about.

What commit XYZ your next commit should build on is already recorded by
HEAD (which in turn often refers to the tip of the branch you have checked
out by pointing at it).

HEAD (and the tip of the branch) is *supposed* to be updated by operations
you do from the work tree *alone*, not by push from sideways.  Therefore
there is no such duplicated information kept.

The index is an obvious place to save that duplicated information if you
really wanted to, and you are welcome to try it again, but I have to warn
you that we have already tried this once and the fallout was not very
pretty.