完整的信息:

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)

当前回答

如果你在一个不区分大小写的文件系统(Windows或OS X)下运行git,如果有两个同名但大写不同的分支,就会发生这种情况,例如user_model_changes和user_model_changes,因为两个远程分支将匹配相同的跟踪引用。

删除错误的远程分支(你不应该有只有大小写不同的分支),然后git远程删除原点,一切都应该正常工作

其他回答

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

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

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

然后手动操作:

git pull [remote_name] [branch_name]

我找到了改动的地方。

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

我也遇到了同样的问题,我只是删除了远程分支,并从master中创建了新的分支,并将我从旧功能分支到新功能分支的更改合并在一起。现在我尝试了拉和推的要求,它为我工作

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

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

我知道这很旧了,但我有自己的办法。因为我使用的是源树,这个错误发生是因为有人创建了一个新的分支。源树对此感到困惑。在我按下“remote branch to pull”组合框旁边的“Refresh”按钮后,似乎sourcetree已经更新了分支列表,现在我可以成功拉起。