oplaTech About Teaching Archive
Oplatek's external memory

How to compress multiple commits into one in Git by rebasing?

Problem is that if you are not the maintainer of a repository merging creates
more complicated history than rebasing.

# Git merging history
a - b - c
/ \
1 Z
\ /
2 - 3 - 4

1 - a -2 -b -c -3 -4 -Z

Rebasing creates single line history which is easier to maintain
and further more you can compress your work into single commit by
following commands described at this blog

git log --oneline
git rebase -i SHA1

Nice trick is to use rebase --autosquash. Check help for more info!

Another solution is to use a merge command with --squash option.