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

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


当前回答

以admin cd打开Git Bash文件夹, Git添加。 Git commit -m "your message" Git推 他现在要么使用内置凭证,要么要求用户名/pw, 如果内置凭据或用户名/pw不起作用,创建一个PAT并关闭要求凭据的窗口,将弹出一个要求PAT的屏幕

其他回答

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

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

git remote prune origin

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

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

直接的答案

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

按步骤执行上述命令

删除文件。git/logs/refs/remotes/origin/[锁定分支名称]

这对我很有用

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