我只有分支主和我得到这个错误,每次我尝试“git拉”:

error: Couldn't set refs/remotes/origin/master
From /var/lib/git/xxx/project
 ! a0f80ea..49177a3  master     -> origin/master  (unable to update local ref)

当我执行“git pull origin master”时,我得到:

error: Couldn't set ORIG_HEAD
fatal: Cannot update the ref 'ORIG_HEAD'.

我一直在寻找,却找不到原因


当前回答

我有同样的错误,我从git桌面应用程序拉。所以我尝试从DOS命令窗口更新,并得到相同的问题。

然后我尝试了解决方案“git gc -prune=now” .

git gc——prune=now:这已经解决了我所面临的上述问题。

谢谢。

其他回答

这里发生了什么? 对远程分支的本地引用被更改,因此当你运行git pull时,git找不到任何相应的远程分支,因此它失败了。

git remote prune origin

实际上是清除这个本地引用,然后再次运行git pull。

建议:为了安全起见,请使用——试运行选项

我通过删除锁定的分支文件来修复这个问题。它可能看起来很粗糙,我不知道为什么它能起作用,但它解决了我的问题(即你得到的相同错误)

删除: .git/refs/remotes/origin/[锁定的分支名称]

然后我就跑了

git fetch

git文件恢复了自己,完全修复了

这对我很有用

rm .git/logs/refs/remotes/origin/master 

如果你最近更改了密码,并且有一些奇特的东西集成了你的Windows和Linux登录,也会发生这个错误(无法更新本地ref)。

试着在你的git仓库根文件夹中使用这个命令:

rm .git/logs/refs/remotes/origin/master