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

前端 未结 25 1125
隐瞒了意图╮
隐瞒了意图╮ 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:19

    For me, the problem was the 'double quotation marks' into merge message. So when I removed the double mark, all magically worked. I hope to help someone. (Sorry for my poor English)

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

    I had a work tree with master and an another branch checked out in two different work folders.

    PS C:\rhipheusADO\Build> git worktree list
    C:/rhipheusADO/Build         7d32e6e [vyas-cr-core]
    C:/rhipheusADO/Build-master  91d418c [master]
    
    PS C:\rhipheusADO\Build> cd ..\Build-master\
    
    PS C:\rhipheusADO\Build-master> git merge 7d32e6e #Or any other intermediary commits
    Updating 91d418c..7d32e6e
    Fast-forward
     Pipeline/CR-MultiPool/azure-pipelines-auc.yml | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    PS C:\rhipheusADO\Build-master> git ls-remote
    From https://myorg.visualstudio.com/HelloWorldApp/_git/Build
    53060bac18f9d4e7c619e5170c436e6049b63f25        HEAD
    7d32e6ec76d5a5271caebc2555d5a3a84b703954        refs/heads/vyas-cr-core 
    
    PS C:\rhipheusADO\Build-master> git merge 7d32e6ec76d5a5271caebc2555d5a3a84b703954
    Already up-to-date
    
    PS C:\rhipheusADO\Build>  git push
    Total 0 (delta 0), reused 0 (delta 0)
    To https://myorg.visualstudio.com/HelloWorldApp/_git/Build
       91d418c..7d32e6e  master -> master
    

    If you need to just merge the latest commit:

    git merge origin/vyas-cr-core 
    git push
    

    And is same as what I've always done:

    git checkout master # This is needed if you're not using worktrees
    git pull origin vyas-cr-core
    git push
    
    0 讨论(0)
  • 2020-12-04 06:20

    It's a silly suggestion, but make sure there is no typo in the branch name!

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

    You might also encounter this error if you are not using origin keyword and the branch isn't one of your own.

    git checkout <to-branch> 
    git merge origin/<from-branch>
    
    0 讨论(0)
  • 2020-12-04 06:20

    The branch which you are tryin to merge may not be identified by you git at present so perform git branch and see if the branch which you want to merge exists are not, if not then perform git pull and now if you do git branch, the branch will be visible now, and now you perform git merge <BranchName>

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

    This answer is not related to the above question, but I faced a similar issue, and maybe this will be useful to someone. I am trying to merge my feature branch to master like below:

    $ git merge fix-load
    

    for this got the following error message:

    merge: fix-load - not something we can merge

    I looked into above all solutions, but not none of the worked.

    Finally, I realized the issue cause is a spelling mistake on my branch name (actually, the merge branch name is fix-loads).

    0 讨论(0)
提交回复
热议问题