Developer Notes

3 - Photo by marianne bos on Unsplash

Git tips 3: managing two parallel versions

The code I deliver to my customers are usually just a little bit different than the code I use for development. Config files contain different connection strings, dependencies are in different locations, that sort of thing.

Because of this I usually have two branches:

  • master – my main development branch
  • production – the customer version

Before a delivery to the customer I merge the finalized changes from master to production.

Merging is a breeze with Git, but in this scenario it keeps breaking me up. Git will by default try to do a Fast-Forward merge. That means that the changes aren’t really merged, the head for the production branch is just set to the head of the master branch, effectively overwriting the small but significant differences in the production branch.

To prevent this from happening disable fast-forward merge ( --no-ff ). After the merge I like to verify it all still works so I prevent Git from committing the merge ( --no-commit ).

The final merge command looks like this:

git merge --no-ff –no-commit master