devroom.io/content/posts/2016-08-17-squash-git-commits-when-merging.md
2019-06-05 14:32:16 +02:00

39 lines
1.3 KiB
Markdown

+++
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][squash-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:
``` shell
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.
``` shell
git commit -m "Apply workaround for Oracle DB 12"
```
Done.
[squash-rebase]: https://ariejan.net/2011/07/05/git-squash-your-latests-commits-into-one/