Git Restore With Reflog
Mar 25, 2021
usecase
The aim of this how-to-guide🏁 is to show the restore of data of for example a deleted commit via git reflog
.
reflog
stands for REFERENCE LOGS- record when the tips of branches and other references were updated in the LOCAL REPO
1. Instructions
- Run
git reflog
- Run
git checkout -b <recoverBranch> <sha>
- the name of the
<recoverBranch>
is IRRELEVANT & CUSTOM - the
sha
is CRUCIAL & FIXED - you may have to commit/stash all changes in the working area before creating a detached head
- e.g.
git checkout -b restoreTests 284270a
- Recover data by placing them somewhere else
- Return to
master
bygit checkout master
- Delete the ad-hoc branch by
git branch -D <recoverBranch>