Recovering Git repository from objects only

前端 未结 3 2015
长情又很酷
长情又很酷 2020-12-10 07:17

I have a Windows box which has taken it into it\'s head to delete most of a Git repository (must have tripped the Important Work Detector ;). All I have left (that I can fin

相关标签:
3条回答
  • 2020-12-10 07:43

    The first thing that I would try is to initialize a new repository with git init. Then I'd copy the objects directory from the dead repository into the new repository. Then I'd run git fsck in the new repository.

    With some luck you'll see a whole lot of dangling objects and with a bit more luck some of the dangling objects will be commit objects which will be the tips of lost branches.

    If you run git show and/or git log on these commits you may be able to recognize some of the branches.

    To "recover" them you can just use git branch to recreate named branches.

    0 讨论(0)
  • 2020-12-10 07:49

    If you haven't already tried git checkout master, I'd start with that.

    0 讨论(0)
  • 2020-12-10 07:54

    try using this post

    How to recover Git objects damaged by hard disk failure?

    that answer may have some *nix related info. Let me know if it helps.

    Ill see what it does.

    0 讨论(0)
提交回复
热议问题