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
In My case, the Problem was in Branch Name. My new branch name contains brackets, Once I renamed it and remove brackets, It's sorted.
For me the problem occured when I tried this:
git merge -s ours --no-commit --allow-unrelated-histories <remote name>/develop
So actually I should have written master
instead of develop
,because master was the branch name of Subtree,not my actual branch.
This error suggest that the branch from where you want to merge changes (i.e. in you case branch-name) is not present in you local, so you should checkout the branch and fetch the local changes. Checkout to your master branch and fetch, then follow the below steps:
git checkout branch-name
git pull
git checkout new-branch-name
git merge branch-name
I had the same problem... I am a complete beginner
In my case it happened cause I was trying to do: git merge random_branch/file.txt
My problem was solved when I retired the file.txt and let just the branch name (lol) kkfdskfskdfs
git merge random_branch
worked pretty well
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.
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.