needleinthehay.de

Combine multiple Commits into a single one

The git log in the own branch can get quite messy sometimes. It’s a good idea to clean that up, before creating a Pull Request. The following workflow combines commits into a single one.

Don’t use this approach on a branch with many developers working on it!

1.) Make sure working directory is clean:

2.) Identify the number of commits () to combine:

a45e273 (HEAD -> <MYBRANCH>, <ORIGIN>) A commit message
e5bdaca Improved something
64a4cb1 Reverted
aeb755a Ups
c36e41a Everything better now
ae16a49 It should work now
[...]

3.) Rebase:

pick a45e273 A commit message
s Improved something
s 64a4cb1 Reverted
s aeb755a Ups

[...]

4.) Force push: