问题
How I can configure some confirmation on git push command in concrete branch? I have production branch and sometimes I forgot that I in production branch and push not those changes.
回答1:
One potential solution would be to remove the config associated with 'production' branch.
git config --unset branch.<branch>.remote
git config --unset branch.<branch>.merge
That way, you have to mention to what remote you want to pull from (or push to, for that matter).
If you define an alias for the pull which:
- pull
- and then remove the remote and merge config for that branch,
you are sure you will not be able, for that branch, to do a simple "git pull" without entering additional parameters.
回答2:
You can git fetch
, then git status
will tell you if new commits have been pushed.
回答3:
All you need is the pre-hook for the commits into protected branches like "master".
This blog on "how-to-prevent-push-to-master" should help you.
PS: GIT Version 1.8.2 or above needed.
来源:https://stackoverflow.com/questions/6839853/confirmation-of-git-push-command