Skip to content

Instantly share code, notes, and snippets.

@zawyelwin
Last active September 20, 2021 05:53
Show Gist options
  • Save zawyelwin/c3b8fd6774c276835ca2ebab35ac27cd to your computer and use it in GitHub Desktop.
Save zawyelwin/c3b8fd6774c276835ca2ebab35ac27cd to your computer and use it in GitHub Desktop.
Remove last commit from remote git repository

Be careful that this will create an "alternate reality" for people who have already fetch/pulled/cloned from the remote repository. But in fact, it's quite simple:

git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit

If you want to still have it in your local repository and only remove it from the remote, then you can use:

git push origin +HEAD^:<name of your branch, most likely 'master'>

source

Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment