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?
I tried
instead of
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.
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:
The below method worked for me everytime.
this answer is not related above question but I am face this kind issue maybe this use full to some one , i am merge my feature branch to master like below
for this ,i am look into above all solutions but not work anyone,
Finally i found the issue on the spelling mistake on my branch name (actually the merge branch name is fix-loads).
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.
This should work, but if you receive an error saying
you need to fetch the remote (probably, but not necessarily, "origin") before checking out the branch: