Do note that this does not apply if you did not commit your changes before you did
git reset --hard
Thanks jessekphillips!
1 day, you are updating your branch...
git pull origin/branch_name
# got merge request? Hmmm... I wonder why π€
And you saw that you have newer changes after merging it, compared to the origin.
So you want to just reset it to the same state as the origin, then you did
git reset --hard origin/branch_name
.
.
.
OH MY GOD!!! π±
You realize that you got the merge request because you actually committed some changes! God knows when π΅.
So here's the git command that gonna save you!
Introducing Git reflog
!
git reflog
some other commits...
39386b35 HEAD@{8}: some commit message
18cb2ce7 HEAD@{9}: the commit that I want to revert back to!
f9386b35 HEAD@{10}: some commit message
some other commits...
git reset HEAD@{9}
AND I just save your day! Just kidding, here's the answer that actually save our day!
Top comments (2)
I would like to be clear that --hard will in fact delete any uncommitted changes, and those changes are lost and won't show in reflog.
Yes, you are right, thanks for the info!