修复损坏的 git 存储库 - 如何重新开始
我是 git 的新手,对我的存储库的工作方式感到沮丧..或者在本例中不起作用..所以我从 git hub 中删除了它,删除了项目上的 git 文件夹并计划重新开始。
现在,当我尝试设置一个新的存储库时,我收到很多消息,例如:
warning: You appear to be on a branch yet to be born.
warning. Forcing checkout of HEAD
当我尝试运行第一次提交时,我看到:
error: invalid object 8bcb4b5fd612e3ad55fb07e4bed087c55afd0861
fatal: git-write-tree: error building trees
我运行了 git fsck 并发现我丢失了一堆 blob。
我怎样才能把石板擦干净然后再试一次呢?
I am somewhat of a newbie with git and was frustrated with how my repo was working.. or in this case not working.. so I deleted it off of git hub, deleted the git folder on the project and was planning to start fresh.
Now when i try and set up a fresh repo I am getting a lot of messages like :
warning: You appear to be on a branch yet to be born.
warning. Forcing checkout of HEAD
when I try and run the first commit I see :
error: invalid object 8bcb4b5fd612e3ad55fb07e4bed087c55afd0861
fatal: git-write-tree: error building trees
I ran git fsck and see that I am missing a bunch of blobs.
How can I just wipe the slate clean and try again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,
请注意
clean
步骤,该步骤可防止将许多以前未跟踪的内容添加到新存储库中。一个好的 .gitignore 对于防止类似的影响大有帮助。如果需要,您可以手动迁移部分/全部旧配置,例如
(或简单地复制它)
我不会详细讨论对潜在远程克隆/分支的影响:)
有多种方法可以协调类似的事情,但就目前而言,这似乎回答了你的问题。
Ok,
Note the
clean
step that prevents a lot of previously untracked stuff from being added to the new repo. A good .gitignore goes a long way to prevent effects like that.If you want, you can manually migrate some/all of the old configuration, like
(or simply copy it)
I'll not go into obvious details about impact on potential remote clones/branches :)
There are ways to reconcile things like that, but for now, this seems to answer your question.