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

Re: Running 'git pull' from an unnamed branch

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 6, 2009, 01:05 UTC
Message-ID
<7v3acmoalw.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<3f4fd2640904051433u199587c3wc9bf080d138944e7@mail.gmail.com>
Reece Dunn <msclrhd@googlemail.com> writes:
Show 12 quoted lines
> diff --git a/git-pull.sh b/git-pull.sh
> index 8a26763..00a72dd 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -97,6 +97,10 @@ error_on_no_merge_candidates () {
>  	echo "try again (e.g. 'git pull <repository> <refspec>')."
>  	echo "See git-pull(1) for details on the refspec."
>  	echo
> +	echo "You may not be on a branch. In this case, you need to move"
> +	echo "onto the branch you want to pull to (usually master):"
> +	echo "    git checkout <branch>"
> +	echo

I do not think that is necessarily what the user wanted to hear. Often I create trial merges on a detached HEAD when I hear a pull-request from others (I have a few work trees that share the repository with my primary working area, made with contrib/workdir/git-new-workdir script, and their HEAD are typically detached at the tip of the master), and in such a use case, the first line of the instruction in the context in your patch is the right thing to give. I do not want to have the resulting trial merge anywhere on my real branches, and do not want to be told to switch to any of them.

We really should teach people, especially the new ones early on, that "git push" and "git pull" are meant to be told where-to/from and what, and how to drive these commands with explicit arguments, before letting them rely on the default configuration blindly without understanding the underlying concepts.

The automation given by the configuration variables is certainly nice, and the default created by "clone", "remote add" and "checkout -b" (with its implicit "track") may make them simpler to operate for every day life, but there is a limit. Working on a detached HEAD is an ultimate free-form hacking, and you do not even necessarily _want_ to have a "while my HEAD is detached, please always do this" default configured.

Previous: Reece DunnNext: Reece Dunn
Message 8 of 12 in “Running 'git pull' from an unnamed branch”
  1. Reece DunnApr 5, 2009
  2. Sverre RabbelierApr 5, 2009
  3. Markus HeidelbergApr 5, 2009
  4. Reece DunnApr 5, 2009
  5. Markus HeidelbergApr 5, 2009
  6. Björn SteinbrinkApr 5, 2009
  7. Reece DunnApr 5, 2009
  8. Junio C HamanoApr 6, 2009
  9. Reece DunnApr 6, 2009
  10. Björn SteinbrinkApr 6, 2009
  11. Reece DunnApr 6, 2009
  12. Markus HeidelbergApr 6, 2009

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.