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?
Thanks!
-u : The -u flag creates a tracking reference for every branch that you successfully push onto the remote repository. The local branch you push is automatically linked with the remote branch. This allows you to use commands such as git pull without any arguments.
git push is most commonly used to publish an upload local changes to a central repository. After a local repository has been modified a push is executed to share the modifications with remote team members.
Commit - committing is the process which records changes in the repository. Think of it as a snapshot of the current status of the project. Commits are done locally. Push - pushing sends the recent commit history from your local repository up to GitHub.
Git version 2.10 (released Sep 2, 2016) added --push-option
to git push
:
-o --push-option
Transmit the given string to the server, which passes them to the pre-receive as well as the post-receive hook. The given string must not contain a NUL or LF character.
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
where:
<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.
I would do this in another way and keep one branch that has the receive-deploy action and another branch which does not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With