完整的信息:

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)

当前回答

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

其他回答

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

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

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

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

然后手动操作:

git pull [remote_name] [branch_name]

我找到了改动的地方。

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

经过不断的搜索,这是对我有效的解决方案,需要清除/移除上游

git branch --unset-upstream

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

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

不幸的是,GIT命令如修剪、重置或推送对我不起作用。修剪工作了一次,然后问题又回来了。

对我有效的永久解决方案是手动编辑git文件。只需转到项目的.git文件夹,然后在文本编辑器(如notepad++)中打开packd -refs文件。然后导航到失败的分支所在行,并将其guid更新为预期的guid。

如果你有这样的信息:

错误:不能锁定ref 'refs/remotes/origin/feature/branch_xxx':是在425ea23facf96f51f412441f41ad488fc098cf23,但预期383de86fed394ff1a1aeefc4a522d886adcecd79

然后在文件中找到带有refs/remotes/origin/feature/branch_xxx的行。这里的guid将是预期的(第二个)- 383de86fed394ff1a1aeefc4a522d886adcecd79。您需要将其更改为真正的(第一个)- 425ea23facf96f51f412441f41ad488fc098cf23。

对其他失败的分支重复操作,您就可以继续了。有时在重新获取后,我不得不重复相同的分支,我已经“固定”之前。在重新获取时,GIT更新guids并给你最新的一个。

无论如何,这个问题不是一个节目的中止。分支列表得到更新。这是一个相当大的警告。