It's not entirely clear what you want, but if you want to disable a bare git push
all together, you can do:
git config --local push.default nothing
This means that the bare git push
will assume no default refspec, and you must specify it. The only other thing I can think to do is create an alias, and use that for pushing. So, something like this in your .gitconfig
:
[aliases]
p = "!_() { cur=$(git symbolic-ref HEAD); if test \"$cur\" = refs/heads/master -a -z \"$1\"; then { echo \"please specify push target\"; exit 1; } ; fi; git push \"$@\" ; }; _"
Then git p
would reject pushing when no other command line parameters are specified on the command line when on master. Otherwise, it'd use the push default.
I believe that's all the flexibility that you can achieve from git right now. If you need something more, perhaps talking about it on the git list may convince someone to implement a feature for you. You'll need a compelling use-case though.