How to resolve git's “not something we can mer

2019-01-12 19:42发布

I just encountered a problem when merging a branch into master in git. First, I got the branch name by running git ls-remote. Let's call that branch "branch-name". I then ran git merge branch-name command and got the following result:

fatal: branch-name - not something we can merge

How do I resolve this error?

16条回答
Fickle 薄情
2楼-- · 2019-01-12 19:58

I tried

git merge <branch-name> "Commit-message"

instead of

git merge <branch-name> -m "Commit-message"
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-01-12 20:00

For posterity: Like AxeEffect said... if you have no typos check to see if you have ridiculous characters in your local branch name, like commas or apostrophes. Exactly that happened to me just now.

查看更多
别忘想泡老子
4楼-- · 2019-01-12 20:02

If the string containing the reference is produced by another Git command (or any other shell command for that matter), make sure that it doesn't contain a return carriage at the end. You will have to strip it before passing the string to "git merge".

Note that it's pretty obvious when this happens, because the error message in on 2 lines:

merge: 26d8e04b29925ea5b59cb50501ab5a14dd35f0f9
 - not something we can merge
查看更多
劫难
5楼-- · 2019-01-12 20:04

The below method worked for me everytime.

git checkout master
git pull
git checkout branch-name-to-be-merged
git pull
git checkout branch-name
git pull
git merge branch-name-to-be-merged
查看更多
霸刀☆藐视天下
6楼-- · 2019-01-12 20:04

this answer is not related above question but I am face this kind issue maybe this use full to some one , i am merge my feature branch to master like below

$ git merge fix-load
merge: fix-load - not something we can merge

for this ,i am look into above all solutions but not work anyone,

Finally i found the issue on the spelling mistake on my branch name (actually the merge branch name is fix-loads).

查看更多
相关推荐>>
7楼-- · 2019-01-12 20:05

As shown in How does "not something we can merge" arise?, this error can arise from a typo in the branch name because you are trying to pull a branch that doesn't exist.

If that is not the problem (as in my case), it is likely that you don't have a local copy of the branch that you want to merge. Git requires local knowledge of both branches in order to merge those branches. You can resolve this by checking out the branch to merge and then going back to the branch you want to merge into.

git checkout branch-name
git checkout master
git merge branch-name

This should work, but if you receive an error saying

error: pathspec 'remote-name/branch-name' did not match any file(s) known to git.

you need to fetch the remote (probably, but not necessarily, "origin") before checking out the branch:

git fetch remote-name
查看更多
登录 后发表回答