# refresh local branches with remote
git remote update origin --prune
# Replace last commit with new
git commit --amend
git commit --amend -m "the updated message"
You create a commit "A", and then modified files. Now you want a single commit including "A" changes and these new changes.
# add modified files into staging
git add .
# auto amend last commit and replace it with a new one
git commit --amend --no-edit
# assume N = 2
git rebase -i HEAD~2
# mark 1st as "r", the else as "s"
# modify the commit message, then :wq!