{"thread":{"id":"18738","subject":"Running 'git pull' from an unnamed branch","startedAt":"2009-04-05T21:33:57Z","lastAt":"2009-04-06T21:05:27Z","messageCount":12,"participants":["Reece Dunn","Sverre Rabbelier","Markus Heidelberg","Björn Steinbrink","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"110465","messageId":"3f4fd2640904051433u199587c3wc9bf080d138944e7@mail.gmail.com","threadId":"18738","inReplyTo":null,"subject":"Running 'git pull' from an unnamed branch","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2009-04-05T21:33:57Z","receivedAt":"2009-04-05T21:33:57Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"Hi,\n\nHere is something I have just recently tripped up on.\n\n$ git pull\nYou asked me to pull without telling me which branch you\nwant to merge with, and 'branch..merge' in\nyour configuration file does not tell me either.  Please\nname which branch you want to merge on the command line and\ntry again (e.g. 'git pull <repository> <refspec>').\nSee git-pull(1) for details on the refspec.\n\nIf you often merge with the same branch, you may want to\nconfigure the following variables in your configuration\nfile:\n\n    branch..remote = <nickname>\n    branch..merge = <remote-ref>\n    remote.<nickname>.url = <url>\n    remote.<nickname>.fetch = <refspec>\n\nSee git-config(1) for details.\n\n$ git branch\n* (no branch)\n  master\n\nRunning `git checkout master && git pull` fixed the above issue. The\npatch below improves the error message for users that are in this\nstate.\n\nAlso, is \"branch..remote\" valid? Should this be \"branch.remote\"?\n\n- Reece\n\n>From c3933ba95f705dae1a41cb2ee6a282f3be0a6ab0 Mon Sep 17 00:00:00 2001\nFrom: Reece Dunn <msclrhd@gmail.com>\nDate: Sun, 5 Apr 2009 22:27:10 +0100\nSubject: [PATCH] Improve the message when pulling to a headless branch.\n\n---\n git-pull.sh |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 8a26763..00a72dd 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -97,6 +97,10 @@ error_on_no_merge_candidates () {\n \techo \"try again (e.g. 'git pull <repository> <refspec>').\"\n \techo \"See git-pull(1) for details on the refspec.\"\n \techo\n+\techo \"You may not be on a branch. In this case, you need to move\"\n+\techo \"onto the branch you want to pull to (usually master):\"\n+\techo \"    git checkout <branch>\"\n+\techo\n \techo \"If you often merge with the same branch, you may want to\"\n \techo \"configure the following variables in your configuration\"\n \techo \"file:\"\n-- \n1.6.0.4\n"},{"id":"110467","messageId":"fabb9a1e0904051437i75ea0aeci33759a464a412a17@mail.gmail.com","threadId":"18738","inReplyTo":"3f4fd2640904051433u199587c3wc9bf080d138944e7@mail.gmail.com","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-04-05T21:37:39Z","receivedAt":"2009-04-05T21:37:39Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sun, Apr 5, 2009 at 23:33, Reece Dunn <msclrhd@googlemail.com> wrote:\n> +       echo \"You may not be on a branch. In this case, you need to move\"\n> +       echo \"onto the branch you want to pull to (usually master):\"\n> +       echo \"    git checkout <branch>\"\n> +       echo\n\nPlease, there's already 17 lines of spam each time I type 'git pull',\nlet's not embed the entire user manual!\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"110470","messageId":"200904052342.44856.markus.heidelberg@web.de","threadId":"18738","inReplyTo":"3f4fd2640904051433u199587c3wc9bf080d138944e7@mail.gmail.com","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-05T21:42:44Z","receivedAt":"2009-04-05T21:42:44Z","isPatch":false,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Reece Dunn, 05.04.2009:\n> Hi,\n> \n> Here is something I have just recently tripped up on.\n> \n> $ git pull\n> \n> [..]\n> \n> $ git branch\n> * (no branch)\n>   master\n> \n> Running `git checkout master && git pull` fixed the above issue. The\n> patch below improves the error message for users that are in this\n> state.\n> \n> Also, is \"branch..remote\" valid? Should this be \"branch.remote\"?\n\nThe current branch has no name, so there is nothing between the two\ndots. For clarification: branch.(no branch).remote\n\n> +\techo \"You may not be on a branch. In this case, you need to move\"\n> +\techo \"onto the branch you want to pull to (usually master):\"\n> +\techo \"    git checkout <branch>\"\n> +\techo\n\nNot being on a branch is not the general case when you receive this\nmessage. Maybe determining if you are not on a branch and adjusting the\nmessage acordingly is an option.\n\nMarkus\n"},{"id":"110474","messageId":"20090405220855.GA20356@atjola.homenet","threadId":"18738","inReplyTo":"3f4fd2640904051433u199587c3wc9bf080d138944e7@mail.gmail.com","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-04-05T22:08:55Z","receivedAt":"2009-04-05T22:08:55Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.04.05 22:33:57 +0100, Reece Dunn wrote:\n> $ git pull\n> You asked me to pull without telling me which branch you\n> want to merge with, and 'branch..merge' in\n> your configuration file does not tell me either.  Please\n> name which branch you want to merge on the command line and\n> try again (e.g. 'git pull <repository> <refspec>').\n> See git-pull(1) for details on the refspec.\n> \n> If you often merge with the same branch, you may want to\n> configure the following variables in your configuration\n> file:\n> \n>     branch..remote = <nickname>\n>     branch..merge = <remote-ref>\n>     remote.<nickname>.url = <url>\n>     remote.<nickname>.fetch = <refspec>\n> \n> See git-config(1) for details.\n> \n> $ git branch\n> * (no branch)\n>   master\n> \n> Running `git checkout master && git pull` fixed the above issue. The\n> patch below improves the error message for users that are in this\n> state.\n\nIt doesn't \"fix\" anything, you're simply doing something different.\n\n\"git pull\" while on a detached HEAD can't work, there are no defaults\nthat could be used. But e.g. \"git pull origin master\" would do, fetching\n\"master\" from \"origin\" and merging it to the commit you have checked\nout.\n\nYour \"git checkout master && git pull\" does something else. It uses the\nconfigured pull defaults for \"master\" to fetch something and merge it to\n\"master\".\n\n> Also, is \"branch..remote\" valid? Should this be \"branch.remote\"?\n\nThat's a bug, but it should not be branch.remote. The config setting is\nbranch.<name>.remote. As you were on a detached HEAD, there is no\n\"<name>\", and the code that generates the error message doesn't handle\nthat correctly. I'd even say that in this case, the whole \"If you often\nmerge ...\" part makes no sense at all, you simply can't setup pull\ndefaults for a detached HEAD.\n\n> +\techo \"You may not be on a branch. In this case, you need to move\"\n> +\techo \"onto the branch you want to pull to (usually master):\"\n\nHm? Neither do you really need to move to a branch, nor is \"master\"\nreally _that_ special that it is warranted to recommend checking it\nout... IMHO.\n\nBjörn\n"},{"id":"110476","messageId":"3f4fd2640904051515x797e10b5ia20543f207084a60@mail.gmail.com","threadId":"18738","inReplyTo":"200904052342.44856.markus.heidelberg@web.de","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2009-04-05T22:15:40Z","receivedAt":"2009-04-05T22:15:40Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"2009/4/5 Markus Heidelberg <markus.heidelberg@web.de>:\n> Reece Dunn, 05.04.2009:\n>> Hi,\n>>\n>> Here is something I have just recently tripped up on.\n>>\n>> $ git pull\n>>\n>> [..]\n>>\n>> $ git branch\n>> * (no branch)\n>>   master\n>>\n>> Running `git checkout master && git pull` fixed the above issue. The\n>> patch below improves the error message for users that are in this\n>> state.\n>>\n>> Also, is \"branch..remote\" valid? Should this be \"branch.remote\"?\n>\n> The current branch has no name, so there is nothing between the two\n> dots. For clarification: branch.(no branch).remote\n\nOk. I see now.\n\n>> +     echo \"You may not be on a branch. In this case, you need to move\"\n>> +     echo \"onto the branch you want to pull to (usually master):\"\n>> +     echo \"    git checkout <branch>\"\n>> +     echo\n>\n> Not being on a branch is not the general case when you receive this\n> message. Maybe determining if you are not on a branch and adjusting the\n> message acordingly is an option.\n\nSo, something like:\n\nFrom 59e8b71be1585a3a6c8c1233811c19ef0022b3e5 Mon Sep 17 00:00:00 2001\nFrom: Reece Dunn <msclrhd@gmail.com>\nDate: Sun, 5 Apr 2009 23:15:03 +0100\nSubject: [PATCH] Improve the message when pulling to a headless branch.\n\n---\n git-pull.sh |   40 +++++++++++++++++++++++-----------------\n 1 files changed, 23 insertions(+), 17 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 8a26763..f263c04 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -90,23 +90,29 @@ error_on_no_merge_candidates () {\n\n \tcurr_branch=${curr_branch#refs/heads/}\n\n-\techo \"You asked me to pull without telling me which branch you\"\n-\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n-\techo \"your configuration file does not tell me either.  Please\"\n-\techo \"name which branch you want to merge on the command line and\"\n-\techo \"try again (e.g. 'git pull <repository> <refspec>').\"\n-\techo \"See git-pull(1) for details on the refspec.\"\n-\techo\n-\techo \"If you often merge with the same branch, you may want to\"\n-\techo \"configure the following variables in your configuration\"\n-\techo \"file:\"\n-\techo\n-\techo \"    branch.${curr_branch}.remote = <nickname>\"\n-\techo \"    branch.${curr_branch}.merge = <remote-ref>\"\n-\techo \"    remote.<nickname>.url = <url>\"\n-\techo \"    remote.<nickname>.fetch = <refspec>\"\n-\techo\n-\techo \"See git-config(1) for details.\"\n+\tif [ -n \"$curr_branch\" ]; then\n+\t\techo \"You asked me to pull without telling me which branch you\"\n+\t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n+\t\techo \"your configuration file does not tell me either.  Please\"\n+\t\techo \"name which branch you want to merge on the command line\"\n+\t\techo \"and try again (e.g. 'git pull <repository> <refspec>').\"\n+\t\techo \"See git-pull(1) for details on the refspec.\"\n+\t\techo\n+\t\techo \"If you often merge with the same branch, you may want to\"\n+\t\techo \"configure the following variables in your configuration\"\n+\t\techo \"file:\"\n+\t\techo\n+\t\techo \"    branch.${curr_branch}.remote = <nickname>\"\n+\t\techo \"    branch.${curr_branch}.merge = <remote-ref>\"\n+\t\techo \"    remote.<nickname>.url = <url>\"\n+\t\techo \"    remote.<nickname>.fetch = <refspec>\"\n+\t\techo\n+\t\techo \"See git-config(1) for details.\"\n+\telse\n+\t\techo \"You may not be on a branch. In this case, you need to\"\n+\t\techo \"move to the branch you want to pull to (usually master):\"\n+\t\techo \"    git checkout <branch>\"\n+\tfi\n \texit 1\n }\n\n-- \n1.6.2.2.414.g81aa.dirty\n"},{"id":"110477","messageId":"200904060028.03542.markus.heidelberg@web.de","threadId":"18738","inReplyTo":"3f4fd2640904051515x797e10b5ia20543f207084a60@mail.gmail.com","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-05T22:28:03Z","receivedAt":"2009-04-05T22:28:03Z","isPatch":false,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Reece Dunn, 06.04.2009:\n> 2009/4/5 Markus Heidelberg <markus.heidelberg@web.de>:\n> > Reece Dunn, 05.04.2009:\n> >> +     echo \"You may not be on a branch. In this case, you need to move\"\n> >> +     echo \"onto the branch you want to pull to (usually master):\"\n> >> +     echo \"    git checkout <branch>\"\n> >> +     echo\n> >\n> > Not being on a branch is not the general case when you receive this\n> > message. Maybe determining if you are not on a branch and adjusting the\n> > message acordingly is an option.\n> \n> So, something like:\n\n>  git-pull.sh |   40 +++++++++++++++++++++++-----------------\n>  1 files changed, 23 insertions(+), 17 deletions(-)\n> \n> diff --git a/git-pull.sh b/git-pull.sh\n> index 8a26763..f263c04 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -90,23 +90,29 @@ error_on_no_merge_candidates () {\n> \n>  \tcurr_branch=${curr_branch#refs/heads/}\n> \n> -\techo \"You asked me to pull without telling me which branch you\"\n> -\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n> -\techo \"your configuration file does not tell me either.  Please\"\n> -\techo \"name which branch you want to merge on the command line and\"\n> -\techo \"try again (e.g. 'git pull <repository> <refspec>').\"\n> -\techo \"See git-pull(1) for details on the refspec.\"\n> -\techo\n> -\techo \"If you often merge with the same branch, you may want to\"\n> -\techo \"configure the following variables in your configuration\"\n> -\techo \"file:\"\n> -\techo\n> -\techo \"    branch.${curr_branch}.remote = <nickname>\"\n> -\techo \"    branch.${curr_branch}.merge = <remote-ref>\"\n> -\techo \"    remote.<nickname>.url = <url>\"\n> -\techo \"    remote.<nickname>.fetch = <refspec>\"\n> -\techo\n> -\techo \"See git-config(1) for details.\"\n> +\tif [ -n \"$curr_branch\" ]; then\n> +\t\techo \"You asked me to pull without telling me which branch you\"\n> +\t\techo \"want to merge with, and 'branch.${curr_branch}.merge' in\"\n> +\t\techo \"your configuration file does not tell me either.  Please\"\n> +\t\techo \"name which branch you want to merge on the command line\"\n> +\t\techo \"and try again (e.g. 'git pull <repository> <refspec>').\"\n> +\t\techo \"See git-pull(1) for details on the refspec.\"\n> +\t\techo\n> +\t\techo \"If you often merge with the same branch, you may want to\"\n> +\t\techo \"configure the following variables in your configuration\"\n> +\t\techo \"file:\"\n> +\t\techo\n> +\t\techo \"    branch.${curr_branch}.remote = <nickname>\"\n> +\t\techo \"    branch.${curr_branch}.merge = <remote-ref>\"\n> +\t\techo \"    remote.<nickname>.url = <url>\"\n> +\t\techo \"    remote.<nickname>.fetch = <refspec>\"\n> +\t\techo\n> +\t\techo \"See git-config(1) for details.\"\n> +\telse\n> +\t\techo \"You may not be on a branch. In this case, you need to\"\n> +\t\techo \"move to the branch you want to pull to (usually master):\"\n> +\t\techo \"    git checkout <branch>\"\n> +\tfi\n>  \texit 1\n>  }\n> \n\nYes, on something like this I thought, but the proposed solution is not\nthe right thing to do, see the response from Björn.\n\nMaybe something like \"You are not on a branch, so there cannot be a\nconfiguration for git-pull. You have to explicitly tell the repository\nand refspec.\" or so.\n\nMarkus\n"},{"id":"110478","messageId":"3f4fd2640904051529t2421ccccrb7ca71fee5119d7@mail.gmail.com","threadId":"18738","inReplyTo":"20090405220855.GA20356@atjola.homenet","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2009-04-05T22:29:57Z","receivedAt":"2009-04-05T22:29:57Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"2009/4/5 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> On 2009.04.05 22:33:57 +0100, Reece Dunn wrote:\n>> Running `git checkout master && git pull` fixed the above issue. The\n>> patch below improves the error message for users that are in this\n>> state.\n>\n> It doesn't \"fix\" anything, you're simply doing something different.\n>\n> \"git pull\" while on a detached HEAD can't work, there are no defaults\n> that could be used. But e.g. \"git pull origin master\" would do, fetching\n> \"master\" from \"origin\" and merging it to the commit you have checked\n> out.\n\nSure.\n\n> Your \"git checkout master && git pull\" does something else. It uses the\n> configured pull defaults for \"master\" to fetch something and merge it to\n> \"master\".\n\nThe two cases depend on if you want to stay with the detached HEAD or not.\n\n>> Also, is \"branch..remote\" valid? Should this be \"branch.remote\"?\n>\n> That's a bug, but it should not be branch.remote. The config setting is\n> branch.<name>.remote. As you were on a detached HEAD, there is no\n> \"<name>\", and the code that generates the error message doesn't handle\n> that correctly. I'd even say that in this case, the whole \"If you often\n> merge ...\" part makes no sense at all, you simply can't setup pull\n> defaults for a detached HEAD.\n\nYup. In my revised patch, I have it displaying a different message\n(the one I added) instead of the default one you get at the moment.\n\n>> +     echo \"You may not be on a branch. In this case, you need to move\"\n>> +     echo \"onto the branch you want to pull to (usually master):\"\n>\n> Hm? Neither do you really need to move to a branch, nor is \"master\"\n> really _that_ special that it is warranted to recommend checking it\n> out... IMHO.\n\nI said \"usually master\" to give a hint to the casual/newbie user. The\nexact wording that is outputted in this case can be figured out. It\ncan also mention the case you highlighted.\n\n- Reece\n"},{"id":"110497","messageId":"7v3acmoalw.fsf@gitster.siamese.dyndns.org","threadId":"18738","inReplyTo":"3f4fd2640904051433u199587c3wc9bf080d138944e7@mail.gmail.com","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-06T01:05:15Z","receivedAt":"2009-04-06T01:05:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Reece Dunn <msclrhd@googlemail.com> writes:\n\n> diff --git a/git-pull.sh b/git-pull.sh\n> index 8a26763..00a72dd 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -97,6 +97,10 @@ error_on_no_merge_candidates () {\n>  \techo \"try again (e.g. 'git pull <repository> <refspec>').\"\n>  \techo \"See git-pull(1) for details on the refspec.\"\n>  \techo\n> +\techo \"You may not be on a branch. In this case, you need to move\"\n> +\techo \"onto the branch you want to pull to (usually master):\"\n> +\techo \"    git checkout <branch>\"\n> +\techo\n\nI do not think that is necessarily what the user wanted to hear.  Often I\ncreate trial merges on a detached HEAD when I hear a pull-request from\nothers (I have a few work trees that share the repository with my primary\nworking area, made with contrib/workdir/git-new-workdir script, and their\nHEAD are typically detached at the tip of the master), and in such a use\ncase, the first line of the instruction in the context in your patch is\nthe right thing to give.  I do not want to have the resulting trial merge\nanywhere on my real branches, and do not want to be told to switch to any\nof them.\n\nWe really should teach people, especially the new ones early on, that \"git\npush\" and \"git pull\" are meant to be told where-to/from and what, and how\nto drive these commands with explicit arguments, before letting them rely\non the default configuration blindly without understanding the underlying\nconcepts.\n\nThe automation given by the configuration variables is certainly nice, and\nthe default created by \"clone\", \"remote add\" and \"checkout -b\" (with its\nimplicit \"track\") may make them simpler to operate for every day life, but\nthere is a limit.  Working on a detached HEAD is an ultimate free-form\nhacking, and you do not even necessarily _want_ to have a \"while my HEAD\nis detached, please always do this\" default configured.\n"},{"id":"110522","messageId":"3f4fd2640904060042m438a3a8en2d2746a6216b2b95@mail.gmail.com","threadId":"18738","inReplyTo":"7v3acmoalw.fsf@gitster.siamese.dyndns.org","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2009-04-06T07:42:16Z","receivedAt":"2009-04-06T07:42:16Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"2009/4/6 Junio C Hamano <gitster@pobox.com>:\n> Reece Dunn <msclrhd@googlemail.com> writes:\n>\n>> diff --git a/git-pull.sh b/git-pull.sh\n>> index 8a26763..00a72dd 100755\n>> --- a/git-pull.sh\n>> +++ b/git-pull.sh\n>> @@ -97,6 +97,10 @@ error_on_no_merge_candidates () {\n>>       echo \"try again (e.g. 'git pull <repository> <refspec>').\"\n>>       echo \"See git-pull(1) for details on the refspec.\"\n>>       echo\n>> +     echo \"You may not be on a branch. In this case, you need to move\"\n>> +     echo \"onto the branch you want to pull to (usually master):\"\n>> +     echo \"    git checkout <branch>\"\n>> +     echo\n>\n> I do not think that is necessarily what the user wanted to hear.  Often I\n> create trial merges on a detached HEAD when I hear a pull-request from\n> others (I have a few work trees that share the repository with my primary\n> working area, made with contrib/workdir/git-new-workdir script, and their\n> HEAD are typically detached at the tip of the master), and in such a use\n> case, the first line of the instruction in the context in your patch is\n> the right thing to give.  I do not want to have the resulting trial merge\n> anywhere on my real branches, and do not want to be told to switch to any\n> of them.\n>\n> We really should teach people, especially the new ones early on, that \"git\n> push\" and \"git pull\" are meant to be told where-to/from and what, and how\n> to drive these commands with explicit arguments, before letting them rely\n> on the default configuration blindly without understanding the underlying\n> concepts.\n\nOk, so how about something like:\n\n\"You may not be on a branch. Because of this, you need to specify\nwhere you are pulling from and to. See git-pull(1) for how to do this.\nAlternatively, you can move to a named branch using:\n    git checkout <branch>\"\n\n> The automation given by the configuration variables is certainly nice, and\n> the default created by \"clone\", \"remote add\" and \"checkout -b\" (with its\n> implicit \"track\") may make them simpler to operate for every day life, but\n> there is a limit.  Working on a detached HEAD is an ultimate free-form\n> hacking, and you do not even necessarily _want_ to have a \"while my HEAD\n> is detached, please always do this\" default configured.\n\nHow about the above wording? I have kept the moving to a named branch,\nbut have made it optional and secondary to using git pull with\narguments. This supports the workflow you and others have described,\nwhile retaining the hint for when you don't want to work on a detached\nHEAD - for example, after running bisect - without saying that the\nlatter is required.\n\n- Reece\n"},{"id":"110553","messageId":"20090406100305.GD20356@atjola.homenet","threadId":"18738","inReplyTo":"3f4fd2640904060042m438a3a8en2d2746a6216b2b95@mail.gmail.com","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-04-06T10:03:05Z","receivedAt":"2009-04-06T10:03:05Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.04.06 08:42:16 +0100, Reece Dunn wrote:\n> 2009/4/6 Junio C Hamano <gitster@pobox.com>:\n> > Reece Dunn <msclrhd@googlemail.com> writes:\n> >\n> >> diff --git a/git-pull.sh b/git-pull.sh\n> >> index 8a26763..00a72dd 100755\n> >> --- a/git-pull.sh\n> >> +++ b/git-pull.sh\n> >> @@ -97,6 +97,10 @@ error_on_no_merge_candidates () {\n> >>       echo \"try again (e.g. 'git pull <repository> <refspec>').\"\n> >>       echo \"See git-pull(1) for details on the refspec.\"\n> >>       echo\n> >> +     echo \"You may not be on a branch. In this case, you need to move\"\n> >> +     echo \"onto the branch you want to pull to (usually master):\"\n> >> +     echo \"    git checkout <branch>\"\n> >> +     echo\n> >\n> > I do not think that is necessarily what the user wanted to hear.  Often I\n> > create trial merges on a detached HEAD when I hear a pull-request from\n> > others (I have a few work trees that share the repository with my primary\n> > working area, made with contrib/workdir/git-new-workdir script, and their\n> > HEAD are typically detached at the tip of the master), and in such a use\n> > case, the first line of the instruction in the context in your patch is\n> > the right thing to give.  I do not want to have the resulting trial merge\n> > anywhere on my real branches, and do not want to be told to switch to any\n> > of them.\n> >\n> > We really should teach people, especially the new ones early on, that \"git\n> > push\" and \"git pull\" are meant to be told where-to/from and what, and how\n> > to drive these commands with explicit arguments, before letting them rely\n> > on the default configuration blindly without understanding the underlying\n> > concepts.\n> \n> Ok, so how about something like:\n> \n> \"You may not be on a branch. Because of this, you need to specify\n\nThis should not say \"may\", either you are or you are not on a detached\nHEAD, and git can tell that, so it should not let the user have to\nguess.\n\n> where you are pulling from and to. See git-pull(1) for how to do this.\n> Alternatively, you can move to a named branch using:\n>     git checkout <branch>\"\n\nChecking out a named branch won't solve the \"problem\" on its own.\nConsider this:\n\ngit checkout origin/foo\n   *do stuff*\n\ngit pull\n   *Oh! I need a named branch*\n\ngit checkout -b foo\ngit pull\n   *Still fails*\n\nMaybe:\nYou asked me to pull without telling me which branch you want to merge\nwith and as you have no branch checked out, I cannot look for any\ndefaults to use. Please name which branch you want to merge on the\ncommand line and try again (e.g. 'git pull <repository> <refspec>'). See\ngit-pull(1) for details on the refspec.\n\n\nThat just adjusts the \"you can set some defaults\" part, replacing it\nwith a message telling that a detached HEAD cannot have any defaults.\nWithout implying anything about how the user might want to work, but\ngiving a hint that a branch can have defaults for \"git pull\".\n\nBjörn\n"},{"id":"110559","messageId":"3f4fd2640904060504y452cd8a1pbb9170cd7a357e47@mail.gmail.com","threadId":"18738","inReplyTo":"20090406100305.GD20356@atjola.homenet","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2009-04-06T12:04:39Z","receivedAt":"2009-04-06T12:04:39Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"2009/4/6 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> On 2009.04.06 08:42:16 +0100, Reece Dunn wrote:\n>> 2009/4/6 Junio C Hamano <gitster@pobox.com>:\n>> > Reece Dunn <msclrhd@googlemail.com> writes:\n>> >\n>> >> diff --git a/git-pull.sh b/git-pull.sh\n>> >> index 8a26763..00a72dd 100755\n>> >> --- a/git-pull.sh\n>> >> +++ b/git-pull.sh\n>> >> @@ -97,6 +97,10 @@ error_on_no_merge_candidates () {\n>> >>       echo \"try again (e.g. 'git pull <repository> <refspec>').\"\n>> >>       echo \"See git-pull(1) for details on the refspec.\"\n>> >>       echo\n>> >> +     echo \"You may not be on a branch. In this case, you need to move\"\n>> >> +     echo \"onto the branch you want to pull to (usually master):\"\n>> >> +     echo \"    git checkout <branch>\"\n>> >> +     echo\n>> >\n>> > I do not think that is necessarily what the user wanted to hear.  Often I\n>> > create trial merges on a detached HEAD when I hear a pull-request from\n>> > others (I have a few work trees that share the repository with my primary\n>> > working area, made with contrib/workdir/git-new-workdir script, and their\n>> > HEAD are typically detached at the tip of the master), and in such a use\n>> > case, the first line of the instruction in the context in your patch is\n>> > the right thing to give.  I do not want to have the resulting trial merge\n>> > anywhere on my real branches, and do not want to be told to switch to any\n>> > of them.\n>> >\n>> > We really should teach people, especially the new ones early on, that \"git\n>> > push\" and \"git pull\" are meant to be told where-to/from and what, and how\n>> > to drive these commands with explicit arguments, before letting them rely\n>> > on the default configuration blindly without understanding the underlying\n>> > concepts.\n>>\n>> Ok, so how about something like:\n>>\n>> \"You may not be on a branch. Because of this, you need to specify\n>\n> This should not say \"may\", either you are or you are not on a detached\n> HEAD, and git can tell that, so it should not let the user have to\n> guess.\n>\n>> where you are pulling from and to. See git-pull(1) for how to do this.\n>> Alternatively, you can move to a named branch using:\n>>     git checkout <branch>\"\n>\n> Checking out a named branch won't solve the \"problem\" on its own.\n> Consider this:\n>\n> git checkout origin/foo\n>   *do stuff*\n>\n> git pull\n>   *Oh! I need a named branch*\n>\n> git checkout -b foo\n> git pull\n>   *Still fails*\n>\n> Maybe:\n> You asked me to pull without telling me which branch you want to merge\n> with and as you have no branch checked out, I cannot look for any\n> defaults to use. Please name which branch you want to merge on the\n> command line and try again (e.g. 'git pull <repository> <refspec>'). See\n> git-pull(1) for details on the refspec.\n\nSounds reasonable. I'll update the patch and resubmit later on today.\n\n> That just adjusts the \"you can set some defaults\" part, replacing it\n> with a message telling that a detached HEAD cannot have any defaults.\n> Without implying anything about how the user might want to work, but\n> giving a hint that a branch can have defaults for \"git pull\".\n>\n> Björn\n\n- Reece\n"},{"id":"110630","messageId":"200904062305.28242.markus.heidelberg@web.de","threadId":"18738","inReplyTo":"20090406100305.GD20356@atjola.homenet","subject":"Re: Running 'git pull' from an unnamed branch","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-06T21:05:27Z","receivedAt":"2009-04-06T21:05:27Z","isPatch":false,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Björn Steinbrink, 06.04.2009:\n> Maybe:\n> You asked me to pull without telling me which branch you want to merge\n> with and as you have no branch checked out, I cannot look for any\n> defaults to use.\n\nHmm, let's prove this.\n\n> Please name which branch you want to merge on the\n> command line and try again\n\nSet the config options:\n\n    $ git config branch..remote origin\n    $ git config branch..merge refs/heads/master\n\nVerify them:\n\n    $ git config branch..remote\n    origin\n    $ git config branch..merge\n    refs/heads/master\n\nFine, the unnamed branch is set up properly for git-pull.\nIt _has_ to work.\n\n    $ git checkout origin/master~1\n    Note: moving to \"origin/master\" which isn't a local branch\n    If you want to create a new branch from this checkout, you may do so\n    (now or later) by using -b with the checkout command again. Example:\n      git checkout -b <new_branch_name>\n    HEAD is now at fbdc056... Merge branch 'jc/name-branch'\n\nNever mind. I can ignore this message, I don't need a real branch.\ngit-pull will work, since I set up defaults for the unnamed branch\nproperly.\n\n    $ git pull\n    You asked me to pull without telling me which branch you\n    want to merge with, and 'branch..merge' in\n    your configuration file does not tell me either.  Please\n    name which branch you want to merge on the command line and\n    try again (e.g. 'git pull <repository> <refspec>').\n    See git-pull(1) for details on the refspec.\n    \n    If you often merge with the same branch, you may want to\n    configure the following variables in your configuration\n    file:\n    \n        branch..remote = <nickname>\n        branch..merge = <remote-ref>\n        remote.<nickname>.url = <url>\n        remote.<nickname>.fetch = <refspec>\n    \n    See git-config(1) for details.\n\nHey, above I've made sure, that branch..remote and branch..merge were\nset up properly.\n\nDamn :)\n"}]}