美文网首页Git
Git commit --amend

Git commit --amend

作者: JaedenKil | 来源:发表于2019-03-22 14:34 被阅读0次

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.

相关文章

网友评论

    本文标题:Git commit --amend

    本文链接:https://www.haomeiwen.com/subject/odolvqtx.html