Nicky Hajal Nicky Hajal -4 years ago 198
Git Question

Send arguments from git push

We're using a git post-receive hook to auto-minify our JS and sync our local and remote dev databases.

This is generally desirable, but occasionally not.

Is there anyway to pass an argument to the post-receive hook from git push so this can be disabled when required?


Answer Source

If you keep the post-receive hook, you could decide to run the script based on the ref name of each file.

This hook [...] takes no arguments, but for each ref to be updated it receives on standard input a line of the format:

<old-value> SP <new-value> SP <ref-name> LF


  • <old-value> is the old object name stored in the ref,
  • <new-value> is the new object name to be stored in the ref and
  • <ref-name> is the full name of the ref.

So you could check the branch name from the ref-name, and for some branches, decide not to run your script.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download