Source: /cirosantilli/git-tips/merge-two-or-more-commits-into-one

= Merge two or more commits into one

Before
``
7 my-feature HEAD
|
6
|
5 master
|
4
|
3
|
2
|
1
``

Oh, commit 6 was just a temporary step, should be put together with commit 7:
``
git rebase -i HEAD~2
``

Mark `6` to be squashed.

After:
``
67 my-feature HEAD
|
5 master
|
4
|
3
|
2
|
1
``
Better now, ready to push.