Even though the above solutions do work,This answer is for you in case you want to reverse the clock instead of undoing a git pull.I mean if you want to get your exact repo the way it was X
Mins back then run the command
git reset --hard branchName@{"X Minutes ago"}
Note: before you actually go ahead and run this command please only try this command if you are sure about the time you want to go back to and heres about my situation.
I was currently on a branch develop
, I was supposed to checkout to a new branch and pull in another branch lets say Branch A
but I accidentally ran
git pull origin B
before checking out.
so to undo this change I tried this command
git reset --hard develop@{"10 Minutes ago"}
if you are on windows cmd and get error: unknown switch `e
try adding quotes like this
git reset --hard 'develop@{"10 Minutes ago"}'