我刚刚遇到了一个问题,合并一个分支到主git。首先,我通过运行git ls-remote来获得分支名称。我们称这个分支为“branch-name”。然后我运行git merge branch-name命令,得到如下结果:
fatal: branch-name - not something we can merge
如何解决此错误?
我刚刚遇到了一个问题,合并一个分支到主git。首先,我通过运行git ls-remote来获得分支名称。我们称这个分支为“branch-name”。然后我运行git merge branch-name命令,得到如下结果:
fatal: branch-name - not something we can merge
如何解决此错误?
当前回答
我必须建议先检查所有的分支机构,或者你要找的分支机构是否可用
Git branch -r
从列表中检查
origin/HEAD -> origin/main
origin/feature/branch_1
origin/feature/branch_2
origin/feature/branch_3
origin/feature/branch_4
origin/feature/your branch
建议从origin本身复制清单,然后git合并origin/feature/branch_2。复制粘贴将删除打印错误。
其他回答
当我做一个git合并BRANCH_NAME“some commit message”时,我得到了这个错误-我忘记为提交消息添加-m标志,所以它认为分支名称包括注释。
这是一个愚蠢的建议,但请确保分支名称中没有拼写错误!
虽然听起来很奇怪,但重启电脑有助于解决这个问题。我使用IntelliJ IDEA中的终端,并自动完成分支名称,所以我非常确信这不是分支名称上的拼写错误。
在我的例子中,我试图从git存储库的子目录执行git命令。 请确保它是你用git初始化的目录,而不是它的子目录。
如果您没有使用origin关键字,并且分支不是您自己的分支,也可能遇到此错误。
git checkout <to-branch>
git merge origin/<from-branch>