完整的信息:

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\refs\remotes\origin下的文件夹和文件。 工作,当你没有未推送的更改。

其他回答

我遇到过这个问题,我的解决方案如下:

步骤1:

请先执行该命令。 git gc—Prune=现在

步骤2:

如果运行步骤1命令后没有错误,则在终端中运行下面的命令。 git远程删除源文件

我希望这能解决你的问题。

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

依次使用下面两个命令。

git gc --prune=now

git remote prune origin

这将解决你的问题。

硬重启也会解决这个问题

git reset --hard origin/master

永久解决

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