Lev Savranskiy
Lev Savranskiy

Reputation: 430

Is it possible to configure TortoiseGit master only hook?

Is it possible to configure tortoise git master only hook? Is there a way to automate skipping?

My task is to

Upvotes: 1

Views: 279

Answers (2)

David Deutsch
David Deutsch

Reputation: 19025

Put the following at the top of your hook's script:

if [ `git symbolic-ref --short HEAD` != "master" ]
  then
  exit 0
fi

This will cause the hook to only run on master.

Upvotes: 1

Abhijeet Kamble
Abhijeet Kamble

Reputation: 3201

To answer in a word : yes you can. To achieve this you have to modify your hook accordingly.

Please find below steps for achieving this.

  1. Within your hook, first check which branch you are on (use GIT branch command).
  2. take the output of this command into bash variable and check if its Master.
  3. if its master then only run your logic or else simply return the script with exit0;

Note: exit 0 is used to finish your script normally, if you want your script to stop then use exit 1 as status.

Upvotes: 0

Related Questions