From: Reece Dunn <hidden> Date: 2016-06-15 22:46:33
Hi,
Here is something I have just recently tripped up on.
$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch..merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details on the refspec.
If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:
branch..remote = <nickname>
branch..merge = <remote-ref>
remote.<nickname>.url = <url>
remote.<nickname>.fetch = <refspec>
See git-config(1) for details.
$ git branch
* (no branch)
master
Running `git checkout master && git pull` fixed the above issue. The
patch below improves the error message for users that are in this
state.
Also, is "branch..remote" valid? Should this be "branch.remote"?
- Reece
From c3933ba95f705dae1a41cb2ee6a282f3be0a6ab0 Mon Sep 17 00:00:00 2001
From: Reece Dunn <redacted>
Date: Sun, 5 Apr 2009 22:27:10 +0100
Subject: [PATCH] Improve the message when pulling to a headless branch.
---
git-pull.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
@@ -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>"+echoecho"If you often merge with the same branch, you may want to"echo"configure the following variables in your configuration"echo"file:"
Heya,
On Sun, Apr 5, 2009 at 23:33, Reece Dunn [off-list ref] wrote:
+ 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
Please, there's already 17 lines of spam each time I type 'git pull',
let's not embed the entire user manual!
--
Cheers,
Sverre Rabbelier
From: Markus Heidelberg <hidden> Date: 2016-06-15 22:46:33
Reece Dunn, 05.04.2009:
Hi,
Here is something I have just recently tripped up on.
$ git pull
[..]
$ git branch
* (no branch)
master
Running `git checkout master && git pull` fixed the above issue. The
patch below improves the error message for users that are in this
state.
Also, is "branch..remote" valid? Should this be "branch.remote"?
The current branch has no name, so there is nothing between the two
dots. For clarification: branch.(no branch).remote
+ 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
Not being on a branch is not the general case when you receive this
message. Maybe determining if you are not on a branch and adjusting the
message acordingly is an option.
Markus
From: Björn Steinbrink <hidden> Date: 2016-06-15 22:46:33
On 2009.04.05 22:33:57 +0100, Reece Dunn wrote:
$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch..merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details on the refspec.
If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:
branch..remote = <nickname>
branch..merge = <remote-ref>
remote.<nickname>.url = <url>
remote.<nickname>.fetch = <refspec>
See git-config(1) for details.
$ git branch
* (no branch)
master
Running `git checkout master && git pull` fixed the above issue. The
patch below improves the error message for users that are in this
state.
It doesn't "fix" anything, you're simply doing something different.
"git pull" while on a detached HEAD can't work, there are no defaults
that could be used. But e.g. "git pull origin master" would do, fetching
"master" from "origin" and merging it to the commit you have checked
out.
Your "git checkout master && git pull" does something else. It uses the
configured pull defaults for "master" to fetch something and merge it to
"master".
Also, is "branch..remote" valid? Should this be "branch.remote"?
That's a bug, but it should not be branch.remote. The config setting is
branch.<name>.remote. As you were on a detached HEAD, there is no
"<name>", and the code that generates the error message doesn't handle
that correctly. I'd even say that in this case, the whole "If you often
merge ..." part makes no sense at all, you simply can't setup pull
defaults for a detached HEAD.
+ 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):"
Hm? Neither do you really need to move to a branch, nor is "master"
really _that_ special that it is warranted to recommend checking it
out... IMHO.
Björn
From: Reece Dunn <hidden> Date: 2016-06-15 22:46:33
2009/4/5 Markus Heidelberg [off-list ref]:
Reece Dunn, 05.04.2009:
quoted
Hi,
Here is something I have just recently tripped up on.
$ git pull
[..]
$ git branch
* (no branch)
master
Running `git checkout master && git pull` fixed the above issue. The
patch below improves the error message for users that are in this
state.
Also, is "branch..remote" valid? Should this be "branch.remote"?
The current branch has no name, so there is nothing between the two
dots. For clarification: branch.(no branch).remote
Ok. I see now.
quoted
+ 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
Not being on a branch is not the general case when you receive this
message. Maybe determining if you are not on a branch and adjusting the
message acordingly is an option.
So, something like:
From 59e8b71be1585a3a6c8c1233811c19ef0022b3e5 Mon Sep 17 00:00:00 2001
From: Reece Dunn <redacted>
Date: Sun, 5 Apr 2009 23:15:03 +0100
Subject: [PATCH] Improve the message when pulling to a headless branch.
---
git-pull.sh | 40 +++++++++++++++++++++++-----------------
1 files changed, 23 insertions(+), 17 deletions(-)
@@ -90,23 +90,29 @@ error_on_no_merge_candidates () {curr_branch=${curr_branch#refs/heads/}-echo"You asked me to pull without telling me which branch you"-echo"want to merge with, and 'branch.${curr_branch}.merge' in"-echo"your configuration file does not tell me either. Please"-echo"name which branch you want to merge on the command line and"-echo"try again (e.g. 'git pull <repository> <refspec>')."-echo"See git-pull(1) for details on the refspec."-echo-echo"If you often merge with the same branch, you may want to"-echo"configure the following variables in your configuration"-echo"file:"-echo-echo" branch.${curr_branch}.remote = <nickname>"-echo" branch.${curr_branch}.merge = <remote-ref>"-echo" remote.<nickname>.url = <url>"-echo" remote.<nickname>.fetch = <refspec>"-echo-echo"See git-config(1) for details."+if[-n"$curr_branch"];then+echo"You asked me to pull without telling me which branch you"+echo"want to merge with, and 'branch.${curr_branch}.merge' in"+echo"your configuration file does not tell me either. Please"+echo"name which branch you want to merge on the command line"+echo"and try again (e.g. 'git pull <repository> <refspec>')."+echo"See git-pull(1) for details on the refspec."+echo+echo"If you often merge with the same branch, you may want to"+echo"configure the following variables in your configuration"+echo"file:"+echo+echo" branch.${curr_branch}.remote = <nickname>"+echo" branch.${curr_branch}.merge = <remote-ref>"+echo" remote.<nickname>.url = <url>"+echo" remote.<nickname>.fetch = <refspec>"+echo+echo"See git-config(1) for details."+else+echo"You may not be on a branch. In this case, you need to"+echo"move to the branch you want to pull to (usually master):"+echo" git checkout <branch>"+fiexit1}
From: Markus Heidelberg <hidden> Date: 2016-06-15 22:46:33
Reece Dunn, 06.04.2009:
2009/4/5 Markus Heidelberg [off-list ref]:
quoted
Reece Dunn, 05.04.2009:
quoted
+ 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
Not being on a branch is not the general case when you receive this
message. Maybe determining if you are not on a branch and adjusting the
message acordingly is an option.
@@ -90,23 +90,29 @@ error_on_no_merge_candidates () {curr_branch=${curr_branch#refs/heads/}-echo"You asked me to pull without telling me which branch you"-echo"want to merge with, and 'branch.${curr_branch}.merge' in"-echo"your configuration file does not tell me either. Please"-echo"name which branch you want to merge on the command line and"-echo"try again (e.g. 'git pull <repository> <refspec>')."-echo"See git-pull(1) for details on the refspec."-echo-echo"If you often merge with the same branch, you may want to"-echo"configure the following variables in your configuration"-echo"file:"-echo-echo" branch.${curr_branch}.remote = <nickname>"-echo" branch.${curr_branch}.merge = <remote-ref>"-echo" remote.<nickname>.url = <url>"-echo" remote.<nickname>.fetch = <refspec>"-echo-echo"See git-config(1) for details."+if[-n"$curr_branch"];then+echo"You asked me to pull without telling me which branch you"+echo"want to merge with, and 'branch.${curr_branch}.merge' in"+echo"your configuration file does not tell me either. Please"+echo"name which branch you want to merge on the command line"+echo"and try again (e.g. 'git pull <repository> <refspec>')."+echo"See git-pull(1) for details on the refspec."+echo+echo"If you often merge with the same branch, you may want to"+echo"configure the following variables in your configuration"+echo"file:"+echo+echo" branch.${curr_branch}.remote = <nickname>"+echo" branch.${curr_branch}.merge = <remote-ref>"+echo" remote.<nickname>.url = <url>"+echo" remote.<nickname>.fetch = <refspec>"+echo+echo"See git-config(1) for details."+else+echo"You may not be on a branch. In this case, you need to"+echo"move to the branch you want to pull to (usually master):"+echo" git checkout <branch>"+fiexit1}
Yes, on something like this I thought, but the proposed solution is not
the right thing to do, see the response from Björn.
Maybe something like "You are not on a branch, so there cannot be a
configuration for git-pull. You have to explicitly tell the repository
and refspec." or so.
Markus
From: Reece Dunn <hidden> Date: 2016-06-15 22:46:33
2009/4/5 Björn Steinbrink [off-list ref]:
On 2009.04.05 22:33:57 +0100, Reece Dunn wrote:
quoted
Running `git checkout master && git pull` fixed the above issue. The
patch below improves the error message for users that are in this
state.
It doesn't "fix" anything, you're simply doing something different.
"git pull" while on a detached HEAD can't work, there are no defaults
that could be used. But e.g. "git pull origin master" would do, fetching
"master" from "origin" and merging it to the commit you have checked
out.
Sure.
Your "git checkout master && git pull" does something else. It uses the
configured pull defaults for "master" to fetch something and merge it to
"master".
The two cases depend on if you want to stay with the detached HEAD or not.
quoted
Also, is "branch..remote" valid? Should this be "branch.remote"?
That's a bug, but it should not be branch.remote. The config setting is
branch.<name>.remote. As you were on a detached HEAD, there is no
"<name>", and the code that generates the error message doesn't handle
that correctly. I'd even say that in this case, the whole "If you often
merge ..." part makes no sense at all, you simply can't setup pull
defaults for a detached HEAD.
Yup. In my revised patch, I have it displaying a different message
(the one I added) instead of the default one you get at the moment.
quoted
+ 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):"
Hm? Neither do you really need to move to a branch, nor is "master"
really _that_ special that it is warranted to recommend checking it
out... IMHO.
I said "usually master" to give a hint to the casual/newbie user. The
exact wording that is outputted in this case can be figured out. It
can also mention the case you highlighted.
- Reece