我做了一个git过滤器-repo,现在所有的文件都被删除了。VS代码gitgraph显示repo没有提交。有没有办法恢复我的repo?我的整个项目被删除了,它是一个本地repo,所以我没有任何备份。我已经工作了几个月。它杀了我。请帮助。我绝望了。
我在.git的filter-repo文件夹中有一个commit-map文件,内容如下:
old new
2dcc8b30c4fb13d32f7b448c77a487de1a1d9bd5 0000000000000000000000000000000000000000
4e6915559685c96fe9dc336e1c929f129b603cbc 0000000000000000000000000000000000000000
8bf8d9d278523bf10d50b568eab1f8e5ac6cf8eb 0000000000000000000000000000000000000000
06a897ea4763c3f6034ccdd15e906580dda5f27b 0000000000000000000000000000000000000000
92e8933b223cd7e40bc80f9ac0a2853978bede3d 0000000000000000000000000000000000000000
0b7e2ade7c560078178cb66c0b3acd7d50b5fc10 0000000000000000000000000000000000000000
c296e3f6dd1cfcea8c3ec536c21d17112a9a0222 0000000000000000000000000000000000000000
8ce24d364c43023585109ef680dc2e4dadeeeff6 0000000000000000000000000000000000000000
e9614633a8463e3cdcf0a47206e0639a06aa7527 0000000000000000000000000000000000000000
66f3b8712aa57eaa396251dcc0f5f3285db5ff3b 0000000000000000000000000000000000000000
44442eace317b2b19063cc8c31ffe4a81d216ee7 0000000000000000000000000000000000000000
42877255047bf0376002b98173607a6a89bfab71 0000000000000000000000000000000000000000
54db7f7714302506a137c7b28bcb9a2bad7fc2b4 0000000000000000000000000000000000000000
0f3416c5c8fd3951d7e59a4d23db63f74b9383a3 0000000000000000000000000000000000000000
56379fdd472c102dd50691d9294d27da4b7c9a3d 0000000000000000000000000000000000000000
cc6bb41310efe3e5c2d0f58c956b3dcfd2b9e41a 0000000000000000000000000000000000000000
d7b1b929c943d923e91640b5bcdf49003c6f97cd 0000000000000000000000000000000000000000
f70375aae8340cccfb3c7db235e08464d9cfd1d8 0000000000000000000000000000000000000000
1dfe31b45b82aeb7ef514d81f26547736d60501a 0000000000000000000000000000000000000000
d19e2c4829a2c38c1a0c2adbe60e5a9ca70f7700 0000000000000000000000000000000000000000
7961c20ba12b49ef13996d34f5c4ac6038848418 0000000000000000000000000000000000000000
26ca13021b43c0b8b1b4e6a03948eb091ac6eb12 0000000000000000000000000000000000000000
f03d117ed04f449ae4f4ec1e61e895883acbe491 0000000000000000000000000000000000000000
f0d6ee7e4c778d28f65c864752f0e5cb80648fca 0000000000000000000000000000000000000000
5ce120582976dce9e8921c26adfdd7e5f23814c8 0000000000000000000000000000000000000000
818cd9397dbaa6278f0c33d9ce0ee5115c0c071b 0000000000000000000000000000000000000000
c4cd1317a269f9dc59ded0b9888754c6c205b711 0000000000000000000000000000000000000000
以及参考Map文件,其具有:
c4cd1317a269f9dc59ded0b9888754c6c205b711 0000000000000000000000000000000000000000 refs/heads/master
有什么方法可以恢复。这是一场灾难。我真的哭了。请帮助
编辑:我使用的命令
D:\my_project>git filter-repo --force --subdirectory-filter back\
Parsed 27 commits
New history written in 0.53 seconds; now repacking/cleaning...
Repacking your repo and cleaning out old unneeded objects
Updating files: 100% (6161/6161), done.
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Completely finished after 9.45 seconds.
D:\my_project>git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
.vscode/
front/
nothing added to commit but untracked files present (use "git add" to track)
D:\my_project>git log
fatal: your current branch 'master' does not have any commits yet
2条答案
按热度按时间6yt4nkrj1#
在
git-filter-repo
被调用到当前存储库之前获取原始存储库:这将在当前目录中创建仓库的原始版本(例如my_project)及其提交历史。将仓库的来源设置为远程仓库的url。
强制推送本地存储库以更新远程:
远程仓库现在应该有提交历史和恢复的文件。你可能需要在本地重新克隆它。
tzcvj98z2#
据我所知,从the comments of a post that recommends this command和其他论坛线程,似乎没有办法扭转这一点(虽然我不完全确定)。
无论如何,如果你使用的是IDE,那么IDE很有可能会将对文件所做的更改缓存在历史记录中,然后你可以从那里恢复。我知道Jetbrains IDE(PyCharm,IntelliJ,Clion)有这样的功能,它昨天救了我的命。
要在Jetbrains IDE中做到这一点,您可以选择“文件〉本地历史〉显示历史”,并在运行命令之前恢复快照。
这个答案对你来说肯定太晚了,但也许我可以为别人保存局面。。