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-n
git rebase the-branch-to-be-merged
I solved the problem using this git command, but rebase
is only suited for some cases.
It may happen because that branch is not on your local. before merging use
git fetch origin
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
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:
merge: 26d8e04b29925ea5b59cb50501ab5a14dd35f0f9
- not something we can merge
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