如何解开以前在GIT历史记录中删除的文件?
-
01-10-2019 - |
题
使用 克里斯的答案 在另一个问题上,我可以为我的git存储库提供快照历史。由于其中一个文件不是我历史记录的一部分,而仅在快照中,因此第一个原始提交现在还包含该文件的删除。我该如何撤消?
起初我以为这是相反的 如何从git的历史记录中删除敏感文件, ,但实际上我不想将文件插入历史记录中,而只是从历史记录中删除删除。
解决方案 2
我得到了它:
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> # thanks for reminding, kubi
git commit --amend
git rebase --continue
git tag -d originalHead
编辑 不幸的是,这将使所有标签在旧时间表处留下,请参阅 这里
其他提示
git checkout <commit> <filename>
不隶属于 StackOverflow