繁体   English   中英

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

[英]Restoring git directory while preserving history

我知道您可以按以下方式还原以前删除的目录

git checkout {revision} -- {dir}

但是,已还原目录中所有文件的历史记录已全部消失。 它们都被视为“新”文件。

有没有一种方法可以在还原目录的同时仍保留其文件的历史记录?

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

我在这里找到这个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM