Get "PHP 8 in a Nuthshell" (Now with PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

Git Uncommit

Here’s a handy little Git alias that you can use to undo your last commit. Thanks to Freek sharing this on X.

git config --global alias.uncommit 'reset --soft HEAD~1'

This will create a global Git alias called uncommit that reverts the current repository’s last commit using soft reset and puts the changes back into the staging area.

So, if you want to undo your last commit, you can do it like so.

git uncommit

Bonus: While you’re here, you can list down all the Git aliases you have created using the following command.

git config --list | grep alias

See ya.

Like this article?

Buy me a coffee

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?