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, the first original commit now also contains the deletion of this file. How can I undo that?
At first I thought this was the opposite of How do I remove sensitive files from git’s history, but actually I don't want to insert a file into history but just remove the deletion from history.
To Restore That Important Missing File or Folder:Type Restore files in the search box on the taskbar, and then select Restore your files with File History. Look for the file you need, then use the arrows to see all its versions. When you find the version you want, select Restore to save it in its original location.
You can restore a deleted file from a Git repository using the git checkout command. If you do not know when a file was last deleted, you can use git rev-list to find the checksum of the commit in which that file was deleted. Then, you can check out that commit.
If you accidentally and permanently delete a file, you can recover it using reliable data recovery software and retrieve the file straight from the hard drive. Although this only retrieves the most recent version of the deleted file.
The easiest method is to do a system restore. If the internet history was deleted recently system restore will recover it. To get system restore up and running you can go to the 'start' menu and do a search for system restore which will take you to the feature.
git checkout <commit> <filename>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With