How to update project version numbers using Git?

Let's say I have two branches: develop and feature .

Suppose I also have a file called VersionNumber that has the following content:

BUILD_NUMBER 1

I want to use Git hooks so that when combining feature in develop the BUILD_NUMBER field automatically expands.

I thought of the following process using post-merge hook:

  • Make sure the branch merged into it, develop
  • Update the VersionNumber file by increasing BUILD_NUMBER by 1
  • Add updated file: git add VersionNumber
  • Change commit: git commit --amend -C HEAD --no-verify

Everything works fine to the last command. Git says that I cannot change the commit in the middle of the merge (which is surprising to me since I thought it was post-merge ).

Any tips on how I can do this (using post-merge or any other hook, for that matter)?

+5
source share

Source: https://habr.com/ru/post/1275153/


All Articles