Git commit --amend
2019-03-22 本文已影响0人
JaedenKil
Scenario: When you make changes, commit, and find out something which should be but not included in the former commit.
git commit --amend -m "A new commit message" # Update commit message
git add file # A file should be included in the last commit but gets uncommitted
git commit --amend --no-edit # Add the new staged changes to the former commit
# Commit message will be the same, but commit id will be different
$ git reflog -10
4030437 (HEAD -> optimize_dumpUi) HEAD@{0}: commit (amend): Optimize assert button exist method
f9b9099 (origin/optimize_dumpUi) HEAD@{1}: commit: Optimize assert button exist method
When combining multiple commits into one, consider git rebase
.
Refer to rewriting-history.