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 20:07

This error suggest that the branch from where you want to merge changes (i.e. in you case branch-name) is not present in you local, so you should checkout the branch and fetch the local changes. Checkout to your master branch and fetch, then follow the below steps:

git checkout branch-name
git pull
git checkout new-branch-name
git merge branch-name
查看更多
The star\"
3楼-- · 2019-01-12 20:07

I suggest checking if you are able to switch to the branch that you are trying to merge with.

I got this error even though the branch I wanted to merge with was in local repository and there were no spelling errors.

I ignored my local changes so that I could switch to the branch (Stash or commit can also be preferred). After this I switched back to the initial branch, and the merge was successful.

查看更多
干净又极端
4楼-- · 2019-01-12 20:13

You are getting this error because the branch you want to merge doesn't exist on your local repository.

So, first checkout the brach you want to merge into master branch by the following command:

git checkout branch_name_to_merge

After this try to merge it with master branch by the following command:

git merge branch_name_to_merge
查看更多
狗以群分
5楼-- · 2019-01-12 20:13

I got this error when I did a git merge BRANCH_NAME "some commit message" - I'd forgotten to add the -m flag for the commit message, so it thought that the branch name included the comment.

查看更多
登录 后发表回答