Git找不到sha1 - 我可以废弃历史记录并重新开始吗?

时间:2013-05-10 22:19:16

标签: git github

我已经阅读了无数Q&在这里关于恢复损坏的git存储库。

git gsckgit cat-file -s <sha1>git gc --aggressivegit repack -a -f等等。我甚至尝试从遥控器(github)再次克隆。我已经尝试了所有这些并且仍然会损坏和丢失文件(是的,甚至在github上)。

你能帮助我重新开始吗?如果到现在为止我不关心历史,那么历史上任何事情都会发生核心的命令是什么?并且开始新鲜了?

这是最近的一次尝试:

~> git repack -a -f
Counting objects: 13150, done.
error: unable to find 25cf6740ca26d90a932e59e1337425d7f227a8a8
error: unable to find 26cf4dfed14d3230854008c483982b0b8727ccd1
error: unable to find 41dc657cfca10511a2351b18aaff054504fb9c31
error: unable to find 8bb2dff3a758d12603f4340d4da7eb6c3144749d
error: unable to find cf59f4bbfacb6ac791e3aa1f0c39b3e8d468964b
Delta compression using up to 2 threads.
Compressing objects: 100% (13041/13041), done.
fatal: unable to read 26cf4dfed14d3230854008c483982b0b8727ccd1

1 个答案:

答案 0 :(得分:1)

mkdir clean_repo
cd clean_repo
git init
cp -r ../bad_repo/. .
git add
git commit

这将生成一个新的仓库,然后从旧仓库复制文件(减去.git)。要“修复”GitHub仓库

git remote add origin git@github.com:antirez/redis.git
git push -f origin master