排除git push的配置参考
  当我调用git remote show <remote_name>我会在下面看到 
  Local branches configured for 'git pull':
    master           merges with remote master
  Local refs configured for 'git push':
    master           pushes to master           (up to date)
  我如何排除配置的推送?  所以从主分支的git push会抛出错误,只有push才会被显式的远程名称git push <remote_name> <remote_branch_name> 
  如果您将push.default的push.default更改为nothing那么您将需要每次在所有分支上指定<remote_name>和<remote_branch_name> 。 
  git config --global push.default nothing (删除项目特定配置的 -  global) 
设置完成后,当你推动git时,你会得到类似于以下的错误。
致命的:你没有指定任何推送参数,而push.default是“无”。
更新:
如果您只想禁用自动推送特定分支,我只需删除跟踪配置。
  一种方法是编辑你的项目的.git/config并删除[branch="branchname"]配置。 
  或者以编程方式: git config --unset branch.branchname.remote删除分支的配置的remote=remotename部分。 
  确保您的远程配置没有push配置: 
git config --unset remote.<remote_name>.push
  配置push.default到nothing : 
git config push.default nothing
  不幸的是,似乎git remote show <remote_name>似乎没有考虑到config.push设置(它总是假设'匹配'),因此Local refs configured for 'git push'仍将列在输出中。 
  这并不完全清楚你想要什么,但如果你想禁用一个完整的git push ,你可以这样做: 
git config --local push.default nothing
  这意味着,裸git push将假定没有默认的refspec,你必须指定它。  我唯一能想到的其他事情就是创建一个别名,并将其用于推送。  所以,在.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 "$@" ; }; _"
  然后git p会拒绝推动,当没有其他命令行参数指定在主控上的命令行。  否则,它会使用推送默认值。 
我相信这就是您现在可以通过git实现的所有灵活性。 如果你需要更多的东西,也许在git列表上谈论它可能会说服某人为你实现一个功能。 不过,你需要一个引人注目的用例。
链接地址: http://www.djcxy.com/p/26103.html