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?

  • Amend a past commit from a previously merged branch, while keeping branch history
  • Git(hub): change branch?
  • Lost everything after deleting branch - nothing to commit (working directory clean)
  • How to manage versions of a software in Git at the enterprise situation?
  • Master and topic branch both have changes
  • How do I accept Git branch merge changes in multiple files in one go in Visual Studio Team Explorer?
  • Show commit size in git log
  • How can I generate a Composer author list from Git's commit history?
  • Revert commits unique to a branch
  • Rebase-push cycles for git branches
  • Cordova issue when getting from git plugin wakeuptimer
  • git equivalent of svn status -u
  • 11 Solutions collect form web for “How to resolve git's “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 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

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

    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.

    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.

    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

    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

    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.

    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.

    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.

    I tried
    git merge “Commit-message” instead of
    git merge -m “Commit-message”.

    Git Baby is a git and github fan, let's start git clone.