自缚论坛:简化的git push

来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 14:15:19

使用git已经有了一段时间了
当从远程仓库里clone下一个模块
本地修改后,一般就在master分支上
直接敲入命令
git push

这时,会出现一堆的waring
warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated. This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning: 'nothing' : Do not push anything
warning: 'matching' : Push all matching branches (default)
warning: 'tracking' : Push the current branch to whatever it is tracking
warning: 'current' : Push the current branch



意思是说,你没有配置push的缺省行为,默认把本地所有分支的修改都push到remote
提示要配置push.default,我们再看git手册上对这个的解释
Defines the action git push should take if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line. Possible values are:

nothing do not push anything.
matching push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default.
tracking push the current branch to its upstream branch.
current push the current branch to a branch of the same name.



这样就很明白了,我们可以在tracking分支上配置
git config push.default tracking
来让git push命令默认push当前的分支到对应的remote tracking分支上