Revert back to any previous version from Git Bash
1.Get the log history or commit details from git bash using “git log”
2.From this example , last commit is changes 3 and the hash is “b0f165f2f30d1f90f908238b1b219d322bdeae78”
3.And the current view of “index.php” from changes 3 in web browser looks like
4.Consider, we have to revert back in “Change 1”
5.We have to get the hash of “Change 1” and it is “358f28209947fee399764d4be91e5995532bf4d1”
6.Now in git bash type “git reset –hard 358f28209947fee399764d4be91e5995532bf4d1”
7.And it will looks like –
8.To check the status we also can use “git status” and to check the log we use “git log”
9.If we refresh our “index.php” in browser then we will find the following output –
10.So now our code is in previous version.