Suppose you have commits as follows:
git rebase -i HEAD~3
3 means, you are squashing the last 3 commits. Update text in editor opened, save and close.
HEAD~0 --> Commit 5 eeeeeee
HEAD~1 --> Commit 4 ddddddd
HEAD~2 --> Commit 3 ccccccc
HEAD~3 --> Commit 2 bbbbbbb
HEAD~4 --> Commit 1 aaaaaaa
If you want to squash commits 3, 4 and 5 and make them as a single commit, run the commands below:
HEAD~3 --> Commit 2 bbbbbbb
HEAD~4 --> Commit 1 aaaaaaa
If you want to squash commits 3, 4 and 5 and make them as a single commit, run the commands below:
git rebase -i HEAD~3
3 means, you are squashing the last 3 commits. Update text in editor opened, save and close.
git push -f
Now, the commits would be as follows:
HEAD~0 --> Squashed Commit fffffff
HEAD~1 --> Commit 2 bbbbbbb
HEAD~2 --> Commit 1 aaaaaaa
Now, the commits would be as follows:
HEAD~0 --> Squashed Commit fffffff
HEAD~1 --> Commit 2 bbbbbbb
HEAD~2 --> Commit 1 aaaaaaa
Comments
Post a Comment