我只有分支主和我得到这个错误,每次我尝试“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'.

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


当前回答

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

其他回答

一个命令解决方案[Linux/bash用户]

通过更改文件的所有权来更改权限。

sudo chown用户名-R .git

(将“username”替换为您的用户名)

如果文件的所有者是sudo,则使用sudo。

删除文件也可以解决这个问题。

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

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

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

直接的答案

git remote prune origin
rm .git/refs/remotes/origin/master
git fetch
git pull origin master

按步骤执行上述命令

这对Windows来说已经足够了:

Git包引用——全部

再次克隆存储库,并将.git文件夹复制到破碎的项目中。