Git Amend: Edit a commit message
Sometimes I’ll come up with a better description of what I did in my last commit right after I’ve committed it. Or maybe I forgot to appropriately prefix it or to append the branch name at the en of it. You can easily change the message of of an un published commit my doing git commit --amend --message "new commit message"
. If you already pushed your branch (which happens to me all the time) you can then just git push --force-with-lease
to forcyfully update your remote but making sure nobody pushed in the same branch.
Use this aliases (already included in the Oh My ZSH git plugin)
alias gc! = git commit --amend --message
alias gpf = git push --force-with-lease