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.
👋 Hi there! I'm Amit. I write articles about all things web development. If you like what I do and want me to continue doing the same, I'd like you consider leaving a tip. I'd highly appreciate that. Cheers!