I have placed a file inside .git/hooks named pre-push.sh
I am not making any check, just want to echo some error while pushing to the remote. Below is the .sh file content
protected_branch='test'
echo $protected_branch
exit 1
However it is still allowing to push changes without throwing any error. Need help to find where am i making mistake?
Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.
The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.
Quick tip if you want to skip the pre-commit validations and quickly want to get a commit out there. To get your commit through without running that pre-commit hook, use the --no-verify option. Voila, without pre-commit hooks running!
The name of the hook must be exactly pre-push
(not pre-push.sh
, not pre-push.exe
, not pre-push.py
...)
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