devroom.io/content/blog/2016-08-17-squash-git-commits-when-merging.md

1.3 KiB

+++ date = "2016-08-17" title = "Squash git commits when merging" tags = ["git"] description = "Got a branch where you tried lots of different things to fix that nagging bug, but want to clean up your git history when merging?" slug = "squash-git-commits-when-merging" +++

Today I've been fighting to get our test suite to run against a newly delivered Oracle 12 database. Of course, that didn't work out of the box, so there was some debugging, trial-and-error, and cursing involved. Finally, I managed to get the build back up and running. Yay!

The commit history for this pull request was horrible and some would call it unprofessional, looking at the various commit messages written in anger.

Normally I'd squash all commits together using rebase in the feature branch and create a nice pull request. In this case I just wanted to merge this to develop so the build was working. Turns out this is rather easy:

git checkout develop
git merge --squash fix_for_oracle_12

This applies all changes from the fix_for_oracle_12 branch to your working copy, ready for you to commit in a single commit.

git commit -m "Apply workaround for Oracle DB 12"

Done.