Re: [RFC] Detached-HEAD reminder on commit?
- From
Stephan Beyer <s-beyer@gmx.net>
- Date
- Sep 2, 2008, 21:05 UTC
- Message-ID
- <20080902210524.GB7757@leksak.fem-net>
- In-Reply-To
- <7vk5dujn9h.fsf@gitster.siamese.dyndns.org>
Hi,
Junio C Hamano wrote:
> Pieter de Bie <pdebie@ai.rug.nl> writes: >
[..]
Show 10 quoted lines
> > Vienna:git pieter$ ./git commit --allow-empty -m"test" > > Created commit 6ce62c8b: test > > You are on a detached head, so this commit has not been recorded in a branch. > > If you don't want to lose this commit, checkout a branch and then run: > > git merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c > > > > Are there any comments to this / strong opinions against such a change? > > Unconditionally doing this is too loud for my taste. You probably can do > this in your post-commit hook.
Well, Pieter probably can do this in his post-commit hook. But I think this is useful for usability... especially for beginners who might not even know what a hook is. ;)
For me this felt too loud, too, especially since "git status" and "git commit" (without message option) already tells the user that she is on a detached HEAD. And "git commit -a" is usually done after a "git status", too, isn't it? (I do not use "git commit -a", I *use* the index.)
But nonetheless... Some days ago I accidentally detached my head (hihi) and at the end of the day, after switching and rebasing branches, I noticed that some commits in my branch were "lost"... Such a patch may have helped. (Yes, "git fsck --lost-found" and "git cherry-pick ..." helped.)
So I'm somewhere in between. I think this patch can be useful to minimize some annoyance for git users, but on the other hand the loud output can annoy people if they, for example, use git-commit in scripts (like git-rebase and git-rebase--interactive does).
Regards, Stephan
-- Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F