branching and merging – How to resolve gits not something we can merge error

branching and merging – How to resolve gits not something we can merge error

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 doesnt exist.

If that is not the problem (as in my case), it is likely that you dont 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

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

branching and merging – How to resolve gits not something we can merge error

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.

Leave a Reply

Your email address will not be published.