且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何取消删除以前在git历史中删除的文件?

更新时间:2023-12-03 18:20:04



I got it:

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

编辑不幸的是,这会将所有标签保留在旧时间轴上,请参阅这里

edit unfortunately this will leave all tags at the old timeline, see here