簡體   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