繁体   English   中英

如何解决错误 bad object refs/heads/main (1) after running git pull

[英]How to solve error bad object refs/heads/main (1) after running git pull

当我在 Mac 上运行git pull in Terminal 时如何解决这个错误?

remote: Enumerating objects: 115, done.
remote: Counting objects: 100% (115/115), done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 104 (delta 71), reused 63 (delta 30), pack-reused 0
Receiving objects: 100% (104/104), 3.92 MiB | 3.16 MiB/s, done.
Resolving deltas: 100% (71/71), completed with 9 local objects.
fatal: bad object refs/heads/main (1)
error: https://github.com/[...domain name...]/website.git did not send all necessary objects

背景是我有一个通常可以正常运行的网站。 我在 RStudio 中创建它并将其与 github 同步。Netlify 从那里开始。 以下是设置的基础: https://www.apreshill.com/blog/2020-12-new-year-new-blogdown/

在我对 RStudio 进行更改后,从 RStudio 内部,我通常可以提交然后推送更改。 但这一次,它是这样说的:

 ! [rejected]        HEAD -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/[domain name]/website.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again

所以我 go 到终端并将工作目录更改为存储文件的位置并运行git pull 然后我得到了上面提到的fatal: bad object refs/heads/main (1)错误。 基于How to handle git gc fatal: bad object refs/remotes/origin/HEAD error? ,我试过git gc并得到这个错误:

error: bad ref for .git/logs/HEAD (1)
error: bad ref for .git/logs/refs/heads/main (1)
fatal: bad object refs/heads/main (1)
fatal: failed to run repack

我还尝试git remote set-head origin --auto然后git gc并得到与上面直接相同的错误。

如果我运行cat.git/refs/remotes/origin/HEAD ,它会显示: refs/remotes/origin/main

最后,我在git pull之前尝试git reset --hard ,这给了我原来的错误。

我不确定此时该做什么。 我完全可以从远程服务器获取所有内容并重做我的本地更改。

在您的存储库中存在一个名为.git/refs/heads/main (1)的文件,这也意味着本地分支main (1)存在。 该名称包含分支名称中不允许的空格(请参阅此处),这可能是错误的原因。

(1)后缀可能是偶然出现的。 尝试先从文件名中删除它,然后再运行其他操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM