Say I have two branches: develop
and feature
.
Assume I also have a file called VersionNumber
which has the following content:
BUILD_NUMBER 1
I want to use Git hooks so that, when I merge feature
into develop
, the BUILD_NUMBER
field gets incremented automatically.
I thought about the following process using the post-merge
hook:
- Check that branch being merged into is
develop
- Update the
VersionNumber
file by incrementingBUILD_NUMBER
by 1 - Add the updated file:
git add VersionNumber
- Amend the commit:
git commit --amend -C HEAD --no-verify
It all works fine until the final command. Git says I can't amend the commit in the middle of a merge (which is surprising to me, since I thought this was post-merge
).
Any advice on how I can do this (using post-merge
or any other hook for that matter)?