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条回答
贼婆χ
2楼-- · 2019-01-12 19:50

It's a silly suggestion, but make sure there is no typo in the branch name!

查看更多
等我变得足够好
3楼-- · 2019-01-12 19:51

For me the problem occured when I tried this:

git merge -s ours --no-commit --allow-unrelated-histories <remote name>/develop

So actually I should have written master instead of develop,because master was the branch name of Subtree,not my actual branch.

查看更多
Fickle 薄情
4楼-- · 2019-01-12 19:52

When pulling from a remote upstream, git fetch --all did the trick for me:

git remote add upstream [url to the original repo]
git checkout [branch to be updated]
git fetch --all
git merge upstream/[branch to be updated]

In other cases, I found the "Not something we can merge" error will also happen if the remote (origin, upstream) branch does not exist. This might seem obvious, but you might find yourself doing git merge origin/develop on a repo that only has master.

查看更多
来,给爷笑一个
5楼-- · 2019-01-12 19:53

I had this issue as well. The branch looked like 'username/master' which seemed to confuse git as it looked like a remote address I defined. For me using this

git merge origin/username/master

worked perfectly fine.

查看更多
淡お忘
6楼-- · 2019-01-12 19:54

We got this error because we had a comma (,) in the branch name. We deleted the local branch, then re-checked it under a new name without the comma. We were able to merge it successfully.

查看更多
手持菜刀,她持情操
7楼-- · 2019-01-12 19:55

It may happen because that branch is not on your local. before merging use

git fetch origin
查看更多
登录 后发表回答