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

fatal: branch-name - not something we can merge

如何解决此错误?


当前回答

您正在尝试合并的分支目前可能无法被您的git识别 所以执行 git分支 并且看看你想要合并的分支是否存在,如果不存在则执行 git拉 现在如果你使用git分支,分支就会显示出来, 现在你执行git merge <BranchName>

其他回答

我知道现在回答有点晚了,但我也遇到了同样的问题,所以我运行了以下命令

git checkout master

然后

git pull origin branch-name

它解决了我的问题

我的目标是将Branch2代码合并到Branch1中。

我在合并时得到了下面的消息。

我的分支Branch1和Branch2。请在项目文件夹中使用这些分支。

最初我只有分支1与脉泽,在这种情况下,我得到了下面提到的消息。

现在我已经签入了Branch2。

现在Branch1, Brnach2和master都在我的项目文件夹中。

现在开始合并步骤:

这是什么 起来

最后我们合并了Brnach2和Branch1

原因有很多:

git merge dependabot/npm_and_yarn/storybook/addon-essentials-6.4.19
merge: dependabot/npm_and_yarn/storybook/addon-essentials-6.4.19 - not something we can merge

您有一个具有特殊字符的分支名称。(就像我的情况): 解决方案:从不能合并的分支签出一个具有简单名称的新分支。这可能会有所帮助。

git checkout -b feature-addon
git checkout dev
git merge feature-addon

此错误可能是由于分支名称中的拼写错误引起的,因为您正在尝试拉取一个不存在的分支。 非常愚蠢,但很可能你没有你想合并的分支的本地副本。尝试git fetch来获取它

我必须建议先检查所有的分支机构,或者你要找的分支机构是否可用

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 fetch——所有这些都为我做了一件事:

git remote add upstream [url to the original repo]
git checkout [branch to be updated]
git fetch --all
git merge upstream/[branch to be updated]

在其他情况下,如果远程(起源,上游)分支不存在,我发现“Not something we can merge”错误也会发生。这似乎是显而易见的,但您可能会发现自己在只有master的repo上执行git合并origin/develop。