Thread (27 messages) flat view 27 messages, 5 authors, 2016-06-15

Re: disallowing push to currently checked-out branch

From: Sergio Callegari <hidden>
Date: 2016-06-15 22:46:12

Jeff King wrote:
On Mon, Feb 16, 2009 at 10:17:01AM +0000, Sergio Callegari wrote:

  
quoted
quoted
For people who do not follow the git list regularly, a "HEAD contain the
actual commit" is often called "detached".
      
Could you have that done automatically?
Namely rather to denying push to a branch b where HEAD->b, when you get such
push you detach head?
    
See

  http://article.gmane.org/gmane.comp.version-control.git/108923

for discussion.

-Peff
  
Thanks for the pointer!

However, wrt point 1)
If you set 'detach' option, this clueless user is not helped; he will
     happily keep working and would make tons of commits on detached HEAD,
     and next time he switches to another branch, will lose all of them.
  
I guess that git does not let you commit on a detached head without 
crying out loud.

Furthermore, one could do just a bit more than detaching, namely store 
the fact that head got detached and the name of the branch where the 
head was.
With this, when the unconscious user types git status or git commit the 
system could alert him that head got detached because someone updated 
the branch behind his shoulders from remote... and then suggest the 
option to either create a new branch from the detached head (I believe 
that this is what gets suggested anyway when one tries to commit from a 
detached head) or to stash the current tree status, get back onto the 
former branch and try applying the changes on the new head of the branch.
The flag triggering this warning at a git status or git commit command 
should then be cleared at the first occasion when the head is changed.

To me this seems natural and helpful. Am I missing something?

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