Skip to main content

Squash git commits when merging

·150 words·1 min· ·
Git
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

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.

Related

Rails: Prevent Accidental Debugging Commits
·494 words·3 mins
Rails Git
GPG Sign Your Git Commits
·536 words·3 mins
Gpg Gnupg Security Git
Deploying with git-deploy
·1031 words·5 mins
Deployment Git Rails Devops