Git:git-pull的用法总结

栏目: 编程工具 · 发布时间: 7年前

内容简介:本篇文章总结一下粗读了一遍git pull的作用是从一个仓库或者本地的分支拉取并且整合代码。

本篇文章总结一下 git-pull 的用法,主要过程是基于对官网的完整阅读,记录关键笔记和样例,加上自己的理解。整个过程是这样:

git-pull

粗读了一遍 git-pull 的文档,内容很多,恐怕一篇笔记不足以总结到位,可能要分为多篇笔记来总结。

正文

语法

git pull的作用是从一个仓库或者本地的分支拉取并且整合代码。

git pull [<options>] [<repository> [<refspec>…​]]

描述

git pull 相当于 git fetch 跟着一个 git merge FETCH_HEAD<repository> 是仓库的名字, <refspec> 是分支的名字。如果都不写,会有一个默认值。

一个例子:

     A---B---C master on origin
	/
D---E---F---G master
	^
    origin/master in your repository

远程的 master 分支到了 C ,本地的开发到了 G

	 A---B---C origin/master
	/         \
D---E---F---G---H master

git pull 之后会生成一个新的 H ,合并两个分支。

如果发生了冲突,可以使用 git reset --merge 进行回退。

options(选项)

下面摘录几个常用的选项。

–allow-unrelated-histories By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.

允许无关的历史,这个选项,更多是在更改远程仓库的时候用到。

–ff When the merge resolves as a fast-forward, only update the branch pointer, without creating a merge commit. This is the default behavior.   –no-ff Create a merge commit even when the merge resolves as a fast-forward. This is the default behaviour when merging an annotated (and possibly signed) tag that is not stored in its natural place in refs/tags/ hierarchy.   –ff-only Refuse to merge and exit with a non-zero status unless the current HEAD is already up to date or the merge can be resolved as a fast-forward.

ff 选项,这几个选项是说合并时是否开启 fast-forward ,快速合并,这个有在另外一篇帖子中详细讲解,这里就不赘述了。

实例

实例:默认使用方式

git pull

按照 git branch 设置的默认跟踪的服务器和分支来拉取。

实例:拉取远程服务器 originmaster 分支

git pull origin master

以上所述就是小编给大家介绍的《Git:git-pull的用法总结》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

谁排第一

谁排第一

Amy N. Langville、Carl D. Meyer / 郭斯羽 / 机械工业出版社 / 2014-6 / 49

《谁排第一?关于评价和排序的科学》是首个关于评分和排名科学的著作。它是搜索排序姊妹篇的第二本。本书主要内容有:排名概述、梅西法、科利法、基纳法、埃洛体系、马尔可夫法、攻防评分法、基于重新排序的排名方法、分差、用户偏好评分、处理平局、加入权重、“假如……会怎样”的问题与敏感性、排名聚合、比较排名的方法、数据等。 《谁排第一?关于评价和排序的科学》可作为数学、计算机、网络技术、管理学和数据科学等......一起来看看 《谁排第一》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

SHA 加密
SHA 加密

SHA 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器