问题
When I git pull
in any repository, I always get the following merge error:
aetherboard:shwangster shwangster$ git pull -v
From github.com:sirspinach/shwangster
= [up to date] master -> origin/master
merge: 012012012012012012012012012012012012012012012012012012012012 - not
something we can merge
On the other hand, git fetch
and git merge origin/master
work like a charm. So I've been able to work around this problem for a while. However, I needed to update brew today, and the same error prevents me from doing that.
Here is the output from brew update
, which shows git again attempting to merge with the mysterious 0120120120120...
.
aetherboard:gitrepos shwangster$ brew update
merge: 012012012012012012012012012012012012012012012012012012012012 - not
something we can merge
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
回答1:
There's a clue in the other (pretty much exact duplicate) question that Kaz noted in a comment, that the problem went away when pyenv
was taken out of $PATH
.
Here's the bit from the pull script that takes the FETCH_HEAD
trace and turns it into an argument to git merge
(or to git rebase
when doing a rebasing pull):
merge_head=$(sed -e '/ not-for-merge /d' \
-e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | \
tr '\012' ' ')
(By the way, note that those are tabs before and after not-for-merge
and in the second -e
argument to sed. Cut-and-paste generally turns tabs into spaces, and did here.)
I imagine the sed
part is working correctly and the failure occurs with the tr
invocation. In fact, it looks like whatever tr
is being used, is simply spitting out the 012
string (for a total of 60 characters, or 20 instances of the three-character group—not sure how that happens given that the sed
output is, or should be, a 40-character SHA-1).
If your shell is sh
or bash
, see what:
$ type tr
prints. If you use a csh variant, which tr
will show you what it will run. (I'm not sure off-hand what to use for dash and zsh.) If you get something other than /usr/bin/tr
, that may explain the problem. (If you do get /usr/bin/tr
see what type sed
or which sed
says: these should be /usr/bin/sed
.)
来源:https://stackoverflow.com/questions/27592779/git-pull-always-fails-but-git-fetch-merge-are-fine