How to undelete a file previously deleted in git's history?

本小妞迷上赌 提交于 2019-11-28 05:14:27
git checkout <commit> <filename>
Tobias Kienzler

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!