Skip to content

Instantly share code, notes, and snippets.

@sagarjethi
Last active July 27, 2022 15:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagarjethi/c07723b2f4fa74ad8bdf229166cf79d8 to your computer and use it in GitHub Desktop.
Save sagarjethi/c07723b2f4fa74ad8bdf229166cf79d8 to your computer and use it in GitHub Desktop.
Delete commits from a branch in Git
#### Delete the last commit
For example your last commit
git push origin +aa61ab32^:master
Now you want to delete this commit then an Easy way to do this following
Steps
First reset the branch to the parent of the current commit
Force-push it to the remote.
git reset HEAD^ --hard
git push origin -f
For particular commit, you want to reset is following
git reset bb676878^ --hard
git push origin -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment