Since a push does not lock the "HEAD" ref, there is no guarantee that it
will remain the same for the entire operation of the push.  Practically,
this means that with push.default set to current:

  # on branch push-current-head
  $ git push
  # on another terminal
  $ git checkout master
  # return to the first terminal
  # the push tried to push master!

Avoid this confusion by adding the branch that HEAD resolves to as the
refspec to push (as opposed to the literal "HEAD").  With this change,
the output of the push changes subtly from:

  $ git push
   * [new branch]      HEAD -> push-current-head


  $ git push
   * [new branch]      push-current-head -> push-current-head

Signed-off-by: Ramkumar Ramachandra <>
 builtin/push.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/push.c b/builtin/push.c
index a79038c..d819487 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -198,7 +198,7 @@ static void setup_default_push_refspecs(struct remote 
                if (!branch)
                        die(_(message_detached_head_die), remote->name);
-               add_refspec("HEAD");
+               add_refspec(branch->name);

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to