Version Control – Should Versions Be Bumped in Dev Branches or Master Branch?

branchinggitversion controlversioning

I have released API 1.0.0 in the master branch (default branch). Since then I have separately branched to branches api2/foo and api2/bar, both containing backwards-incompatible changes.

The API version is declared in the source code. Should I bump the version to 2.0.0 in both api2/* branches, or in the master branch?

If I bump version in the master branch, the versions in the source code on api2/* branches will not be updated. If I am to release development builds for the branches, things in API 2 may be used when the project declares to be API 1. As a result, I have to merge the commit in the master branch that bumps the version, but I will mege other changes in the master branch altogether, and I don't want it to happen yet.

On the other hand, if I bump version in dev branches, there will be two commits bumping the versions, so when they are both merged into the master branch, there would potentially be conflicts.

What would be a good solution between these two options?

Best Answer

Version the code when you build a release on your CI server.

Normally this would be on a check in to develop, master if you don't have a develop branch

If you version the feature branches you will get into trouble as there is no clear definition of which is 'the latest' version.

Because you are lacking the develop branch, and both changes are incompatible you will have to:

  • merge foo into master, build v2
  • merge master into bar, fix incompatiblities
  • merge bar into master, build v3
Related Topic