Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pre-push hook not working

Tags:

git

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?

like image 307
Kishan Rajdev Avatar asked Apr 29 '15 08:04

Kishan Rajdev


People also ask

How do I enable pre-commit hook?

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.

How do git pre-commit hooks work?

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.

How do I bypass git pre-commit hook?

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!


1 Answers

The name of the hook must be exactly pre-push (not pre-push.sh, not pre-push.exe, not pre-push.py ...)

like image 115
LeGEC Avatar answered Sep 22 '22 06:09

LeGEC