Thread (50 messages) flat view 50 messages, 13 authors, 2016-06-15

Re: [RFC] Detached-HEAD reminder on commit?

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:45:17

Possibly related (same subject, not in this thread)

On Tue, 2 Sep 2008, Johan Herland wrote:
On Tuesday 02 September 2008, Stephan Beyer wrote:
quoted
Junio C Hamano wrote:
quoted
Pieter de Bie [off-list ref] writes:
quoted
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. ;)
I'm not sure I like this personally, but if we _really_ don't want newbies 
to shoot themselves in the foot, we could make "git commit" fail on a 
detached HEAD unless the user has indicated that s/he knows what's going 
on; i.e. something like this:

Vienna:git pieter$ ./git commit --allow-empty -m"test"
You are on a detached head, so this commit would not be recorded in a
branch. If you don't want to lose this commit, please switch to a (new) 
branch before committing. If you know what you're doing, and want to
proceed on a detached HEAD, please enable commit.detached in your 
configuration (git config --global commit.detached true)

...but I sympathize with those that think this is overkill.
This is going over board indeed.

Adding commits to a detached head is _cool_, and it is also _useful_ in 
many occasions.  Let's not obfuscate that capability.

Adding an extra line of warning when the commit is done is fine, but 
more than that is too much IMHO.


Nicolas
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help