完整的信息:

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 pull

其他回答

我必须从命令行中删除我的分支:

.git\refs\remotes\{my remote}\{**my branch**}

然后手动操作:

git pull [remote_name] [branch_name]

我找到了改动的地方。

注意:我正在使用SourceTree,无法进行拉取。

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

我也有同样的问题,因为我重置到一个旧的提交,即使我已经推送到远程分支。

我通过删除我的本地分支,然后签出原始分支git checkout origin/my_branch,然后执行git checkout my_branch来解决这个问题

我运行这个来解决问题:

git gc --prune=now

我尝试了多种选择,但没有一个对我有效。下面的命令对我很有用。把它放在这里,如果它能帮助人们,以防其他选择不起作用。

Git拉-p

-p --prune Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning. Supplying --prune-tags is a shorthand for providing the tag refspec.

——来源:https://git-scm.com/docs/git-pull文档/ git-pull.txt——p