Git commit: Difference between revisions
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
=Apply Extra Changes to the Latest Commit= | =Apply Extra Changes to the Latest 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". This is equivalent with committing one more time and squashing the last two commits with [[Git Squashing Commits#Procedure|git rebase -I HEAD~1]]. | |||
{{Warn|If the latest 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: | {{Warn|If the latest 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: |
Revision as of 02:14, 31 August 2019
External
Internal
Overview
Apply Extra Changes to the Latest 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". This is equivalent with committing one more time and squashing the last two commits with git rebase -I HEAD~1.
If the latest 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.