0

I run two Heroku servers, one dev and one production. I set up Git with targets so I can do

git push dev ...

and

git push production ...

I push unfinished features that I'm testing all the time to the dev with

git push dev newBranch:master

I know that one of these days, when I'm tired, or overworked or just absent-minded, I'm going to mistakenly type

git push production newBranch:master

and push an untested, unworking feature to our live server and not realize it. Is there some way to build in a warning, so that, when I run

git push production

I get

Warning, you are about to push to the live server, do you want to continue (y/n)

or some other indication shows up on the screen? I would sleep easier at night knowing a guard like that exists.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
J-bob
  • 8,380
  • 11
  • 52
  • 85
  • [Kevin](http://stackoverflow.com/a/27066860/2541573) is right: you should use the `pre-push` hook for this. Alternatively, here is a dirty hack: http://stackoverflow.com/questions/25884007/disable-git-add-command/25886149#25886149 – jub0bs Nov 21 '14 at 17:59

1 Answers1

0

You could use git's pre-push hook.

You can learn more about hooks here, and you likely have example scripts installed with your git distribution (or even in your repo!)

Kevin M Granger
  • 2,375
  • 23
  • 28