完整的信息:

error: Ref refs/remotes/origin/user is at 3636498c2ea7735fdcedc9af5ab3c8689e6abe77 but expected a21359c6cc2097c85775cde6a40105f4bd7100ec
From github.com:{github project url}
 ! a21359c..6273ffc  user -> origin/user  (unable to update local ref)

当前回答

依次使用下面两个命令。

git gc --prune=now

git remote prune origin

这将解决你的问题。

其他回答

请按照如下顺序执行以下命令

git gc --prune=now
git remote prune origin
git pull

永久解决

Git update-ref -d解决了这个错误的实例,例如:

git update-ref -d refs/remotes/origin/user

注意,这不会影响远程。

在我的例子中,后续的git获取再次获取该分支,并且后续的git获取/拉不再给出错误“remote ref is at but expected”。

如果这不起作用,临时修复:

还要注意的是,如果你不关心所讨论的分支(例如,你只想更新master,而不是origin/user),一个git pull的变通方法是获取然后合并你所关心的特定分支,例如。

git fetch # may give an error for a particular branch, but other branches will still be successfully fetched
git merge origin/master

清晰的步骤

在终端 cd / . / /遥控器/参考文献来源 做ls,你会看到一些树枝和头部 移除你认为有问题的分支 rm branchname 如果它不起作用,删除所有分支/HEAD 你可能想拉一把

希望它现在有用。

只需删除\.git\refs\remotes\origin下的文件夹和文件。 工作,当你没有未推送的更改。

我运行这个来解决问题:

git gc --prune=now