Git tip: A quicker, smarter way to merge fixes with the master

4 min read /
Some bugs can be fixed in a matter of minutes. But correctly incorporating your fix into the VCS can take much longer – especially if you have multiple related projects and the bugfix requires minor changes to all of them. Here at K15t, this applies to our Scroll Exporters, for example.

This blogpost will explain how you can speed up the process of merging your fixes with the master branch(es) of your projects.

Current approach at K15t Software

At K15t Software, we currently take the following approach when fixing issues in our Scroll add-ons:

  1. Don't commit fixes directly to the master.
  2. Instead, create a bugfix branch with the name of the issue key (e.g. EXP-317).
  3. Commit all changes to this branch, then merge it with the master using certain parameters.

While this method involves a few extra steps, it does produce a neat history graph like this one:

After committing the fix to the bugfix branch, this means you need to perform all of the following steps:

  1. Make sure the bugfix branch has no uncommitted changes.
  2. Return to the master branch.
  3. Perform the merge (git merge --no-commit --no-ff <FIX_BRANCH_NAME>).
  4. Finally, write a commit message and perform the commit.

If you only need to do this occasionally, it’s not a huge problem – as long as you remember the above steps and the merge parameters. But if you have to go through this process many times over, it will quickly get tedious.

For example, making a minor CSS change to the default templates of our six Scroll Exporters involves updating ten different projects (all six exporters plus the corresponding four example templates on Bitbucket).

Speed up your bugfix merges

As this is too time-consuming to perform manually, we came up with the following script. You need to place it somewhere in your $PATH and then invoke it like this (yes, git can do that):

git merge-fix EXP-317

This will merge the fix with the master branch, using a default commit comment:

If you prefer, you can also specify a custom commit message:

git merge-fix EXP-317 "KEY-53: This is my custom commit message."

The script also carries out the following checks before proceeding:

  • Look for uncommitted changes: The script checks that you have no uncommitted changes in your branch.
  • Make sure fixes are only merged with the master: If you are still in your bugfix branch, the script automatically switches to the master before performing the merge.

Download and use the script to speed up your own merges

You’d like to use our script to automate your own merges? Be our guest – here’s what you need to do:

  1. Download the script here: git-merge-fix (make sure you don’t change the name – prefix 'git-' and no extension).
  2. Place it somewhere in your $PATH.
  3. Make sure it’s marked as executable.
  4. You’re done.

What do you think? Just leave a comment below to discuss it with the community.

If you have any questions or other ideas about this approach, don't hesitate to email us at