I checked out the master branch, and did some changes. Then I committed my changes on the master branch but did not push it to repository.
What I did next is check out the remote master again. Then could not see my local commit anymore.
How could I get my local commit back?
You need to reset the HEAD. Use the following to revert to the previous commit.
git reflog
This will give the list of all the commits with head values. Choose the HEAD for the commit you made to the local master branch.
Then, do the following,
git reset --hard HEAD@<i>
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