How to fully revert the most recent git commit

without using rebase

Sometimes, when I was too stupid to change the git configuration and pushed a commit with the wrong credentials again, I need to revert the most recent commit completely. And every time I have to do this, I need to search for the correct command.

So, for a short note: with the command below the last commit will be erased completely. Unlike a rebase, the commit can't be found in any branch from now on. More information can be found in this great post on Stack Overflow.

git reset --hard HEAD~1

Just great for all kind of mistakes. ;)

Share:

Einen Kommentar verfassen

Ihre E-Mail-Adresse wird nicht veröffentlicht, sie dient nur der Identifikation! Für die Profilbilder wird Gravatar verwendet und reCAPTCHA, um Spam zu vermeiden.

Kommentare 0

Es sind noch keine Kommentare für diesen Beitrag vorhanden.