不能用 git 拉

Cannot pull with git

我们的 git 存储库中有一个名为 feature/TestBapi 的分支。

我创建了到存储库 MyRepoA 的新远程连接:git remote add repo-A-branch ../MyRepoA

当我这样做时 git pull repo-A-branch feature/TestBapi --allow-unrelated-histories 我得到:

fatal: Couldn't find remote ref feature/TestBapi
fatal: The remote end hung up unexpectedly

在我的 git 配置中,我有:

branch.feature/TestBapi.remote=origin
branch.feature/TestBapi.merge=refs/heads/feature/TestBapi

为了验证我的分支是否存在,我做了:git checkout --track origin/feature/TestBapi。我得到:fatal: A branch named 'feature/TestBapi' already exists.

我在这里被难住了。有什么想法吗?

当你说

git pull repo-A-branch feature/TestBapi --allow-unrelated-histories

这意味着“在 repo-A-branch(您已映射到 ../myRepoA)上,找到名为 feature/TestBapi 的分支;获取它;并将结果合并到我当前的分支中。

正如评论中以多种方式指出的那样,分支在../myRepoA中不存在。

当指出这一点时,您回复该分支存在于本地存储库中,and/or 它存在于 origin。这很好,但它并没有改变它 存在于你告诉 git 寻找它的回购协议中的事实。

也许您需要退后一步,回顾一下您尝试 运行 此命令的原因。您期望它完成什么?