2013.11.14(2) ——— git学习之提交远程库
2013.11.14(2)———git学习之提交远程库
gitpush远端库名称本地分支名称:远程分支的名称
git push origin dev:dev
每次这样很麻烦,可以简化为
git push
但是git里面有一个全局变量可以控制这个push的方式
如果执行
git push
会有什么后果呢
git2.0之前会提交所有的分支
git2.0只会提交本分支,并且分支名字一样
push.default 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 branches having the same name in both ends. This is for those who prepare all the branches into a publishable shape and then push them out with a single command. It is not appropriate for pushing into a repository shared by multiple users, since locally stalled branches will attempt a non-fast forward push if other users updated the branch. This is currently the default, but Git 2.0 will change the default to simple. upstream - push the current branch to its upstream branch. With this, git push will update the same remote ref as the one which is merged by git pull, making push and pull symmetrical. See "branch.<name>.merge" for how to configure the upstream branch. simple - like upstream, but refuses to push if the upstream branch’s name is different from the local one. This is the safest option and is well-suited for beginners. It will become the default in Git 2.0. current - push the current branch to a branch of the same name. The simple, current and upstream modes are for those who want to push out a single branch after finishing work, even when the other branches are not yet ready to be pushed out. If you are working with other people to push into the same shared repository, you would want to use one of these.
大体意思是:
nothing:不推任何东西(要来做什么用?)。 matching:将两边名字能匹配的分支推上去。 upstream:将当前分支推到它的upstream分支。 simple:将当前分支推到它的upstream分支,但名字不匹配时拒绝。这是最安全的选项并且git 2.0之后会默认为这个。 current:将当前分支推到与它同名的分支上。
所以想要用gitpush的话就设置一下
git config --global push.default simple
每次提交前,最好都执行
git fetch git rebase
这样防止代码冲突,类似于svn的先update后commit
git fetch 和 git pull git fetch 是把更新了本地分支,但是没有合并 rebase的时候 才会尝试合并 git pull 则会强制更新合并到本地
相关推荐
lljhi0 2020-07-21
huangchunxia 2020-07-08
nebulali 2020-07-05
formula 2020-11-12
huhongfei 2020-11-05
乾坤一碼農 2020-10-27
liumengyanysu 2020-10-22
E哥的aws认证攻略 2020-10-15
tianyafengxin 2020-10-08
guying 2020-10-05
好脑筋不如烂笔头 2020-09-17
nebulali 2020-09-11
佛系程序员J 2020-09-15
fenggit 2020-09-15
JustHaveTry 2020-09-11
兄dei努力赚钱吧 2020-09-06
IngeniousIT 2020-08-25