[英]Recovering files from Git objects
I obliterated all my work and would prefer not to explain how.我抹杀了我所有的工作,不想解释如何。
The only thing I have left are the git objects.我唯一剩下的是 git 对象。 More then anything I would like to recover some of the loss packed Image files.
然后我想恢复一些丢失的打包图像文件。 From the size of the object files I can tell which ones they are.
从 object 文件的大小我可以知道它们是哪些。 Is there a way to turn them back into usable files?
有没有办法把它们变成可用的文件?
if the git objects are still in the correct directory ( .git/objects/xx/xxx…
) you can use git fsck --full
for git to discover them — it will probably list every object in your repository. if the git objects are still in the correct directory (
.git/objects/xx/xxx…
) you can use git fsck --full
for git to discover them — it will probably list every object in your repository. now look for the ones labeled commit
and tag
, those are the ones you want to recover.现在寻找标记为
commit
和tag
的那些,那些是你想要恢复的。
i would probably use a script which creates a branch for each commit object found (eg simply increnting numbers rescue-1
, rescue-2
, etc.).我可能会使用一个脚本,为每个发现的提交 object 创建一个分支(例如,简单地增加数字
rescue-1
, rescue-2
等)。 afterwards use gitk --all
to visualize all your branches and pick the top (most recent) one.之后使用
gitk --all
可视化所有分支并选择顶部(最近的)分支。 create a new branch there rescued-master
.在那里创建一个新的分支
rescued-master
。
checkout your new master branch and run git branch --no-merge
.签出您的新主分支并运行
git branch --no-merge
。 you should get a list of branched off commits, not contained in master.你应该得到一个分支提交的列表,而不是包含在master中。 you probably want to give them a new branch name too.
您可能也想给他们一个新的分支名称。
after you're done, delete all the numbered rescue-
branches.完成后,删除所有编号的
rescue-
分支。
hope that helps and gives aa starting point.希望能有所帮助并给出一个起点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.