The following git steps will reset a code base to a specific commit, deleting all commits made since.
This is not considered git-best-practice as it “rewrites history” by deleting old commits and this can cause issues for collaborators who have pulled the commits you are deleting.
Knowing that, only apply this technique if you are sure that deleting commits is the outcome you want and understand the risks.
For other less destructive ways to revert git history, check out this thread: StackOverflow: How can I revert multiple Git commits?
> git log --oneline
> git reset --hard <commit_hash>
> git push --force
See git history to get hash of the commit you want to revert to:
> git log --oneline
Reset to the hash of the commit you want to revert to:
> git reset --hard <commit_hash>
The above command:
Push the reset:
> git push --force
The above command:
--force flag, which does the push while ignoring checks that prevent overwriting commits on the remote repositoryNo subscriptions, no auto-renewals.
Just a simple one-time payment that helps support my free, to-the-point videos without sponsered ads.
Unlocking gets you access to the notes for this video plus all 200+ guides on this site.
Your support is appreciated. Thank you!