Matthieu Moy <Matthieu.Moy@xxxxxxx> writes: > diff --git a/builtin/push.c b/builtin/push.c > index 31da418..c949187 100644 > --- a/builtin/push.c > +++ b/builtin/push.c > @@ -64,14 +64,23 @@ static void set_refspecs(const char **refs, int nr) > } > } > > -static void setup_push_upstream(void) > +static void setup_push_upstream(struct remote *remote) > { > struct strbuf refspec = STRBUF_INIT; > struct branch *branch = branch_get(NULL); > if (!branch) > - die("You are not currently on a branch."); > + die("You are not currently on a branch (detached HEAD).\n" > + "To push a specific branch and set the remote as upstream, use\n" > + "\n" > + " git push --set-upstream %s <branch-name>\n", > + remote->name); For all the other cases covered in this patch, the sequence that lead to this situation would be like this: git checkout somebranch hack hack hack including commits git push and it is very clear that the user wants to push the current branch to the corresponding place but the user is getting an error because there is no "corresponding place" mapping established yet. I agree "push --set-upstream" is a very good advice to give under that scenario---it would push the history s/he wanted to push right now, while establishing the mapping for later use, both at the same time with a single command. However, I don't think that applies to this case with detached HEAD; it is more likely that the user came here this way: git checkout somebranch~4 ;# the tip 3 are not quite ready hack hack quickfix to do only the sure part of the tip 3 did commit and test git push Maybe the user needed to quickly push out a minimum fix out of the more elaborate work, in which case, what would follow in the workflow is first to: git push origin HEAD:somebranch in order to unblock others. This will then be followed by a more leisurely: git rebase HEAD somebranch to get back to the more elaborate work that is not yet presentable. It is not likely that the end user wanted to: git checkout $not_a_branch_tip ;# detached hack hack hack including commits git push origin an_unrelated_branch and wanted to omit "where and what" part. We are talking about "push the current branch only to corresponding destination" people, so if that unrelated branch were already ready for external consumption, they would have already pushed it out at the end of the session when they were on that branch (and seen the other advice you are adding in this patch). That is why I suggested to advice an explicit push, without checkout nor set upstream, in my original review message. IOW, I think the message should instead suggest: If you want to push the history leading to the current (detached) state now, use git push $remote HEAD:the-branch-you-want-to-push-to -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html