Git Squashing Commits: Difference between revisions
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
=Procedure= | =Procedure= | ||
To squash the most 2 recent commits on the current branch: | |||
git rebase -i HEAD~2 | |||
This will enter an interactive editor, that will allow to specify the commits to squash. In the editor, replace the words "pick" with "squash" next to the commits you want to squash into the commit before it. The commits are listed from old to new, so "before" means the commit above. | |||
Upon applying repository changes, the Git client will give us a change to review and modify the comment associated with the commit. This will be done interactively in the editor: | Upon applying repository changes, the Git client will give us a change to review and modify the comment associated with the commit. This will be done interactively in the editor: |
Revision as of 22:32, 30 July 2019
Internal
Procedure
To squash the most 2 recent commits on the current branch:
git rebase -i HEAD~2
This will enter an interactive editor, that will allow to specify the commits to squash. In the editor, replace the words "pick" with "squash" next to the commits you want to squash into the commit before it. The commits are listed from old to new, so "before" means the commit above.
Upon applying repository changes, the Git client will give us a change to review and modify the comment associated with the commit. This will be done interactively in the editor:
# This is a combination of 2 commits.
# This is the 1st commit message:
Existing comment for commit 1
# This is the commit message #2:
Existing comment for commit 2
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.