我刚刚遇到了一个问题,合并一个分支到主git。首先,我通过运行git ls-remote来获得分支名称。我们称这个分支为“branch-name”。然后我运行git merge branch-name命令,得到如下结果:

fatal: branch-name - not something we can merge

如何解决此错误?


当前回答

当我做一个git合并BRANCH_NAME“some commit message”时,我得到了这个错误-我忘记为提交消息添加-m标志,所以它认为分支名称包括注释。

其他回答

为了子孙后代:就像AxeEffect说的……如果没有错别字,请检查本地分支名称中是否有可笑的字符,如逗号或撇号。刚才我就是这样。

下面的方法每次都对我有效。

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

如果您没有使用origin关键字,并且分支不是您自己的分支,也可能遇到此错误。

git checkout <to-branch> 
git merge origin/<from-branch>

当我做一个git合并BRANCH_NAME“some commit message”时,我得到了这个错误-我忘记为提交消息添加-m标志,所以它认为分支名称包括注释。

这可能听起来很奇怪,但请记住设置你的git电子邮件和名称:

git config --global user.email "MY@EMAIL.COM"
git config --global user.name "FIRST_NAME LAST_NAME"