git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] push: better error messages for detached HEAD and "no destination"

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2011, 23:29 UTC
Message-ID
<7v8vwzhh5g.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1298927645-2716-3-git-send-email-Matthieu.Moy@imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
Show 19 quoted lines
> In both cases, give a hint on what to do next. We mention explicitely
> "detached HEAD" since this is the keyword to look for in documentations.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
>  builtin/push.c |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/push.c b/builtin/push.c
> index 210eb36..48fb050 100644
> --- a/builtin/push.c
> +++ b/builtin/push.c
> @@ -69,7 +69,8 @@ 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"
> +		    "Please, checkout the branch you want to push first or specify it on the command line.");

I agree that it is a good thing to suggest specifying what to push on the command line, but I don't think this "checkout first" is particularly a good advice, as it requires two-step operation that is quite a roundabout way of doing what the user wanted to do: a very specific checkout followed by re-running of a nonspecific push.

Show 14 quoted lines
> @@ -152,7 +153,14 @@ static int do_push(const char *repo, int flags)
>  	if (!remote) {
>  		if (repo)
>  			die("bad repository '%s'", repo);
> -		die("No destination configured to push to.");
> +		die("No destination configured to push to.\n"
> +		    "Either specify the URL from the command line or configure a remote repository using\n"
> +		    "\n"
> +		    "    git remote add <name> <url>\n"
> +		    "\n"
> +		    "and then push using the remote name like\n"
> +		    "\n"
> +		    "    git push <name>\n");
>  	}
This one would be helpful.
Previous: Matthieu MoyNext: Matthieu Moy
Message 6 of 12 in “push: better error messages”
  1. 0/2 push: better error messagesMatthieu Moy, Feb 28, 2011
  2. 1/2 push: better error message when push.default = trackingMatthieu Moy, Feb 28, 2011
  3. 2/2 push: better error messages for detached HEAD and "no destination"Matthieu Moy, Feb 28, 2011
  4. Jay SoffianFeb 28, 2011
  5. Matthieu MoyFeb 28, 2011
  6. Junio C HamanoFeb 28, 2011
  7. 1/2 push: better error messages when push.default = trackingMatthieu Moy, Mar 1, 2011
  8. 2/2 push: better error message when no remote configuredMatthieu Moy, Mar 1, 2011
  9. Junio C HamanoMar 1, 2011
  10. 1/2 push: better error messages when push.default = trackingMatthieu Moy, Mar 2, 2011
  11. 2/2 push: better error message when no remote configuredMatthieu Moy, Mar 2, 2011
  12. Junio C HamanoMar 3, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.