I have added something like that in pre-push
hook:
gs0=$(git status)
pip-dump
gs1=$(git status)
if [ \"gs0\" != \"gs1\" ]
then
git commit -m
You can't: the push
command figures out which commits to push before invoking the hook, and pushes that if the hook exits 0.
I see three options:
My personal preference would be the first of these. A pre-push hook is meant as a "verify that this push is OK" operation, not a "change this push to mean some other different push" operation. So that means you're not working against the "intent" of the software. Use the pre-push hook as a verifier; and if you want a script that invokes git push
after automatically adding a pip-dump
commit if needed, write that as a script, using a different name, such as dump-and-push
.