Last active
October 27, 2022 11:08
-
-
Save UmairJibran/353d2e9ff4484af6948b53630ec7e274 to your computer and use it in GitHub Desktop.
Rollback accidentally made (and pushed) commits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git checkout -b new-branch # new-branch or branch name where you actually wanted to make commit | |
| git checkout master # master or any branch where you have accidentally made commit | |
| git reset --hard HEAD~1 # replace 1 with number of commits you want to go back | |
| git push --force # forces the remote to accept the <local> HEAD as new <remote> HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment