Git Undo: against instant regret
Say you’ve amended once to add a forgotten file, once to change the message, another one to remove a console.log, and you realise you are tired and you need to focus a little bit better. In the case you want to profoundly change a commit or maybe you think the last commit was not needed at all, you can undo your last commit with git reset --soft HEAD~1
.
The committed changes won’t be lost, they go directly to the staging area.
I have this saved as
alias gundo = git reset --soft HEAD~1