- Take me to Video Tutorial
In this section, we will take a took at git reflog command.
- If commit is not neccessary at all and wants to remove then we can run the
git reset --hardcommand: -
$ git reset --hard HEAD~1
- After running this command, that data will be gone forever. But we don't need to be panic at all,
git reflogcommand shows the all actions that have been taken to the repository. This includes resets, reverts and merges.
$ git reflog
-
You can easily undo the mistakes you made in the repository that information
reflogcommand gives us. -
You can get the hash value from the
git reflogcommand as we already see in the previous process.
$ git reset --hard 8ad5
-
After this repository has been set into the previous state.
-
You can see that
git reflogstatus also changed.
$ git reflog
git logandgit reflogmay look smiliar.git logwill show you only information about the commits not the status about repository thatgit reflogdoes.
$ git log
$ git reflog