Reputation: 31
Is it possible to apply hook(VREF) for a specific branch only ?
Currently we have a update_rt(VREF/update_rt) hook. But its by default applying for all branches in git. Could you guide me to apply the hook for a specific branch only.
My configuration is as below:
repo demo RW = @all - VREF/update_rt = @all
Upvotes: 3
Views: 583
Reputation: 312770
Hooks are global; a hook for a given operation will always trigger regardless of your current branch. The way you accomplish what you want is by instrumenting your hook script with appropriate logic that will cause it to only operate when on specific branches. For example:
#!/bin/sh
current_branch=$(git rev-parse --abbrev-ref --symbolic-full-name HEAD)
if [ "$current_branch" != "my_branch" ]; then
echo "wrong branch"
exit
fi
Upvotes: 6