3
Alright, so basically I've managed to cause problems by pushing very late at night. How could I change git push (without forcefully changing git write-protected files) to need "Are you sure?" dialog between 3am and 6am.
3
Alright, so basically I've managed to cause problems by pushing very late at night. How could I change git push (without forcefully changing git write-protected files) to need "Are you sure?" dialog between 3am and 6am.
3
You can install git pre-push hook. Create the file $MYREPO/.git/hooks/pre-push
:
#!/bin/bash
hour=$(date +%H)
if [ $hour -ge 3 ] && [ $hour -lt 6 ]; then
read reply "Are you sure ? [yes/anything else]"
if [ "$reply" == "yes" ]; then
return 0;
else
echo "Cancelling ..."
return 1
fi
else
return 0
fi
have you looked at git hooks (especially pre-push hook) ? – vera – 2017-09-20T12:09:18.483
Hey! I was I not aware of hooks before :) You beat me to the answer, thanks :) – Joonatan Samuel – 2017-09-20T12:29:59.473
I didn't see your comment, already provided a sample of pre-push hook. – vera – 2017-09-20T12:31:03.630