Reputation: 35
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?
Upvotes: 3
Views: 1426
Reputation: 3386
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>
Upvotes: 8