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

前端 未结 2 1254
情深已故
情深已故 2020-12-08 04:35

Using Chris\'s answer on another question I could prepend a snapshot-history to my git repository. Since one of the files is not part of my history but only in the snapshots

相关标签:
2条回答
  • 2020-12-08 04:49

    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

    0 讨论(0)
  • 2020-12-08 04:50
    git checkout <commit> <filename>
    
    0 讨论(0)
提交回复
热议问题