Row back to an Older Git Repo
Git, Tools
Sometimes you might accidentally pull changes from a remote repo by running git pull origin master
inadvertently overwriting local changes.
Fortunately there may be a way to go back to the pre-pulled state.
Run git reflog
. This will provide an output like this:
60a22c5 HEAD@{0}: commit: Side commenting system
66e1412 HEAD@{1}: pull origin master: Fast-forward
deff5af HEAD@{2}: commit: grunt build
477fd3d HEAD@{3}: commit: test setup
497e4b7 HEAD@{4}: commit: sidebar dropdown menu
1e18e81 HEAD@{5}: commit: Live reload enabled, sourcemaps working
8a1a95f HEAD@{6}: commit (initial): First Commit
You can revert to one of these commits. E.g.:
git reset --hard 60a22c5
Git will output a message: HEAD is now at 60a22c5 Side commenting system
and you’ll be back at this commit.
comments powered by Disqus