在保留历史记录的同时恢复git目录

时间:2015-05-15 07:20:23

标签: git restore

我知道你可以恢复以前删除的目录,如下所示

git checkout {revision} -- {dir}

但是,已还原目录中所有文件的历史记录已完全消失。他们都被视为新的'文件。

有没有办法恢复目录,同时仍然保留其文件'历史?

1 个答案:

答案 0 :(得分:0)

git tag originalHead # just in case
git rebase -i <id of the parent of the commit that deleted the file>
# change pick to edit for that commit
git checkout <id of the previous commit> <filename>
git commit --amend
git rebase --continue
git tag -d originalHead

我发现了here

相关问题