Git commit: Difference between revisions
Line 14: | Line 14: | ||
git commit --amend | git commit --amend | ||
'''Possible History Rewrite''': | |||
<span id='History_Rewrite'></span> | <span id='History_Rewrite'></span> | ||
{{Warn|If the last, existing commit that has been amended was pushed in a remote repository, you will need to overwrite it in the remote repository - thus [[Git_Concepts#Rewriting_History|rewriting history]] - with: | {{Warn|If the last, existing commit that has been amended was pushed in a remote repository, you will need to overwrite it in the remote repository - thus [[Git_Concepts#Rewriting_History|rewriting history]] - with: |
Revision as of 02:22, 31 August 2019
External
Internal
Overview
Apply Extra Changes to the Last Commit
If you are in the situation where you committed changes on your current branch, but then you worked a little bit more and want to include these latest changes into the last commit, you can use an "amend commit". An amend commit rplaces the tip of the current branch by creating a new commit. The recorded tree is prepared as usual and the message from the original commit is used as the starting point, instead of an empty message, when no other message is specified from the command line via -m. The new commit has the same parents and author as the current one. This is equivalent with committing one more time and squashing the last two commits with git rebase -i HEAD~1:
git add . git commit --amend
Possible History Rewrite:
If the last, existing commit that has been amended was pushed in a remote repository, you will need to overwrite it in the remote repository - thus rewriting history - with:git push --forceThis is not necessary if the last commit was not pushed yet.
Update a Commit Message that Has Not Been Pushed Yet
git commit --amend
It will start an interactive editor.