欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

2013.11.14(二) ——— git学习之提交远程库

更新时间: 2014-01-05 02:33:52 责任编辑: Author_N1

 

2013.11.14(2) ——— git学习之提交远程库
2013.11.14(2) ——— git学习之提交远程库

git push 远端库名称  本地分支名称 :远程分支的名称

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:将当前分支推到与它同名的分支上。


所以想要用git push的话 就设置一下
git config --global push.default simple




每次提交前,最好都执行
git fetch 
git rebase



这样防止代码冲突,类似于svn的先update后commit


git fetch 和 git pull

git fetch 是把更新了本地分支,但是没有合并 rebase的时候 才会尝试合并
git pull 则会强制更新合并到本地



上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 02:33:52
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/11474/
本文WWW.DOC100.NET DOC100.NET版权所有。