Skip to content

Instantly share code, notes, and snippets.

@bhawanabadlani
Last active July 18, 2023 21:44
Show Gist options
  • Save bhawanabadlani/4976200f209f6cf64f847027d0c800f1 to your computer and use it in GitHub Desktop.
Save bhawanabadlani/4976200f209f6cf64f847027d0c800f1 to your computer and use it in GitHub Desktop.

QUESTION

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 to resolve this error?

ANSWER

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, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment