In this repository we had added the holy grail in holygrail.txt. Unfortunately, we reset our master branch to the initial commit. Now it is time to recover from the mistake.
- Run
source setup.sh(or.\setup.ps1in PowerShell)
We just reset the master branch to the initial commit. We will recover the lost work.
- Use
git logto see that the history is brief - Use
lsto verify thatholygrail.txtis not in the workspace - Use
git reflogto find the commit that addedholygrail.txt - Use
git reset --hardto recover our history and work - Use
git logandlsto see the recovered work - Undo your solution by running
git reset --hard initial-commit - Use
git cherry-pickto restoreholygrail.txt - Compare history and workspace to the solution using reset
- Again, undo your solution using
git reset --hard initial-commit - Force the Git garbage collector to run with
git gc - Try to restore the holy grail using one of the previous solutions
git refloggit cherry-pickgit reset --hardgit log