完整的信息:

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 branch --unset-upstream

其他回答

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

步骤1:

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

步骤2:

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

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

永久解决

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

Git for-each-ref——format='delete %(refname)' refs/original | Git update-ref——stdin Git reflog expire—expire=now—all Git gc -prune=现在

我无法从我的Git回购,并得到相同的错误如上所述。在我的情况下,我执行的步骤是右键单击项目文件夹->单击设置->单击远程->单击删除按钮->提供配置的详细信息远程:“起源”,URL:“”在这个设置页面。>然后点击“添加新的/保存”按钮->点击确定。

经过上述更改,我能够成功地拉/取我想要的分支。

依次使用下面两个命令。

git gc --prune=now

git remote prune origin

这将解决你的问题。