I have a git repository that contains code written in C. One of the files is a Version.c file which contains the line
#define Version_Build "0"
There is one hook,
post-merge, that can be invoked by
git merge. But it works in the local repo.
If you want Git to track down the change, yes, you need add and commit it. This is not proper to be done in the remote repo.
In this hook, you can check if the current branch is
master. If yes, make the change, add and commit. If not, just do nothing else.
No option of
git merge can bypass this hook once it's deployed, which might be annoying sometimes. If case you want to disable the hook, there are some approaches to do the job. Set a flag variable reachable inside the hook, check its value and go on. You could export an environment variable before
git merge and unset it afterwards. Or, you could set a self-defined config key. For example,
git config my.post-merge true or
git config my.post-merge false beforehand. In the hook, check the value of
git config --get my.post-merge. Another method is to change the hook's name, like
mv .git/hooks/post-merge .git/hooks/post-merged. Change it back when you need it.