[git] How to resolve git's "not something we can merge" error

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?

This question is related to git branching-and-merging

The answer is


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

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


This may sounds weird, but remember to setup your git email and name:

git config --global user.email "[email protected]"
git config --global user.name "FIRST_NAME LAST_NAME"

In My case, the Problem was in Branch Name. My new branch name contains brackets, Once I renamed it and remove brackets, It's sorted.


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

git fetch origin

I had the same problem. I fixed it using the command below:

git checkout main
git fetch
git checkout branch_name
git fetch
git checkout main
git fetch
git merge branch_name

The branch which you are tryin to merge may not be identified by you git at present so perform git branch and see if the branch which you want to merge exists are not, if not then perform git pull and now if you do git branch, the branch will be visible now, and now you perform git merge <BranchName>


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.


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.


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

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.


You might also encounter this error if you are not using origin keyword and the branch isn't one of your own.

git checkout <to-branch> 
git merge origin/<from-branch>

I had a work tree with master and an another branch checked out in two different work folders.

PS C:\rhipheusADO\Build> git worktree list
C:/rhipheusADO/Build         7d32e6e [vyas-cr-core]
C:/rhipheusADO/Build-master  91d418c [master]

PS C:\rhipheusADO\Build> cd ..\Build-master\

PS C:\rhipheusADO\Build-master> git merge 7d32e6e #Or any other intermediary commits
Updating 91d418c..7d32e6e
Fast-forward
 Pipeline/CR-MultiPool/azure-pipelines-auc.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

PS C:\rhipheusADO\Build-master> git ls-remote
From https://myorg.visualstudio.com/HelloWorldApp/_git/Build
53060bac18f9d4e7c619e5170c436e6049b63f25        HEAD
7d32e6ec76d5a5271caebc2555d5a3a84b703954        refs/heads/vyas-cr-core 

PS C:\rhipheusADO\Build-master> git merge 7d32e6ec76d5a5271caebc2555d5a3a84b703954
Already up-to-date

PS C:\rhipheusADO\Build>  git push
Total 0 (delta 0), reused 0 (delta 0)
To https://myorg.visualstudio.com/HelloWorldApp/_git/Build
   91d418c..7d32e6e  master -> master

If you need to just merge the latest commit:

git merge origin/vyas-cr-core 
git push

And is same as what I've always done:

git checkout master # This is needed if you're not using worktrees
git pull origin vyas-cr-core
git push

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.


I had the same problem... I am a complete beginner In my case it happened cause I was trying to do: git merge random_branch/file.txt My problem was solved when I retired the file.txt and let just the branch name (lol) kkfdskfskdfs

git merge random_branch worked pretty well


This answer is not related to the above question, but I faced a similar issue, and maybe this will be useful to someone. I am trying to merge my feature branch to master like below:

$ git merge fix-load

for this got the following error message:

merge: fix-load - not something we can merge

I looked into above all solutions, but not none of the worked.

Finally, I realized the issue cause is a spelling mistake on my branch name (actually, the merge branch name is fix-loads).


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.


The below method works for me every time.

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

For me, the problem was the 'double quotation marks' into merge message. So when I removed the double mark, all magically worked. I hope to help someone. (Sorry for my poor English)


In my opinion i had missed to map my local branch with remote repo. i did below and it worked fine.

git checkout master
git remote add origin https://github.com/yourrepo/project.git
git push -u origin master
git pull
git merge myBranch1FromMain

git rebase the-branch-to-be-merged

I solved the problem using this git command, but rebase is only suited for some cases.


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.


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.


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