How to resolve git's “not something we can merge” error

前端 未结 25 1128
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 05:42

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

相关标签:
25条回答
  • 2020-12-04 06:24

    git rebase the-branch-to-be-merged

    I solved the problem using this git command, but rebase is only suited for some cases.

    0 讨论(0)
  • 2020-12-04 06:25

    It may happen because that branch is not on your local. before merging use

    git fetch origin
    
    0 讨论(0)
  • 2020-12-04 06:25

    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
    
    0 讨论(0)
  • 2020-12-04 06:25

    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.

    0 讨论(0)
  • 2020-12-04 06:27

    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
    
    0 讨论(0)
  • 2020-12-04 06:30

    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
    
    0 讨论(0)
提交回复
热议问题