可以结帐和跟踪 git 分支,但不能拉

Mik*_*ini 5 git merge branch source-control pull

因此,我们的 git 存储库中有一个名为creative_market. 我运行运行正常的命令git checkout --track origin/creative_market。应该在creative_market分支上的所有更改都存在。但是,如果我运行,git pull我会收到此错误:

您的配置指定与来自远程的 ref 'creative_market' 合并,但未获取此类 ref。

此外,如果我这样做,git pull origin creative_market我会得到:

致命:找不到远程参考 creative_market

致命:远端意外挂断

运行 agit branch -a清楚地显示:

遥控器/起源/creative_market

我的.git/config文件显示:

[branch "creative_market"]
    remote = origin
    merge = refs/heads/creative_market
Run Code Online (Sandbox Code Playgroud)

这与我的.git/config文件中的其他所有内容一致。

我被难住了。有任何想法吗?

Ste*_*ngs 6

您收到的消息可能表明该creative_market分支不再存在于远程存储库中。可能是这种情况吗?

您可以使用以下命令修复它:

git checkout --track origin/creative_market
git push origin creative_market
Run Code Online (Sandbox Code Playgroud)

另一种稍微长一点的证明发生了什么的方法是执行以下操作:

首先,使用命令创建一个备份 ref git branch creative_market2 origin/creative_market。然后,运行git fetch -p以修剪远程上不再存在的远程跟踪分支。如果确实从远程删除了分支,您将看到如下内容:

[my-repository]$ git fetch -p
 x [deleted]         (none)     -> origin/creative_market
Run Code Online (Sandbox Code Playgroud)

要在远程存储库上重新创建分支,只需将本地引用推送到它:

git push --set-upstream origin creative_market2:creative_market
Run Code Online (Sandbox Code Playgroud)