Confirmation of git push command

半城伤御伤魂 提交于 2019-12-12 22:09:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!