两者之间有什么区别?git pullgit fetch?


当前回答

这张图能帮上忙git pull基本上等于git fetch时当时git merge

This graphic could be of help. git pull is essentially equivalent to git fetch then git merge

其他回答

其中一个使用实例git fetch是,以下将告诉您自您上次拉动以来远程分支的任何变化... 这样您就可以在实际拉动之前检查, 这样就可以改变您当前分支和工作副本中的文件 。

git fetch
git diff ...origin

见见git diff双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双- 双..三点和三点...语法。

git-pull - Fetch from and merge with another repository or a local branch
SYNOPSIS

git pull   …
DESCRIPTION

Runs git-fetch with the given parameters, and calls git-merge to merge the 
retrieved head(s) into the current branch. With --rebase, calls git-rebase 
instead of git-merge.

Note that you can use . (current directory) as the <repository> to pull 
from the local repository — this is useful when merging local branches 
into the current branch.

Also note that options meant for git-pull itself and underlying git-merge 
must be given before the options meant for git-fetch.

如果你想要合并历史,你会拉拉, 你会拉拉,你会拉拉拉,如果你只是"想要的cotz" ,因为有人一直在标记 一些文章在这里。

之间唯一的差别git pullgit fetch是:

git pull从远程分支拉出并合并。

git fetch仅从远程分支获取取取, 但它不合并

i. e. git pull = git 获取 + git 合并...

和差异之间的差别GIT 抓取GIT 调可用下列假设情况解释:(记住图片比文字更响亮!

让我们举一个例子来说明您正在与团队成员一起开展一个项目。 因此,该项目将有一个主要分支, 所有贡献者都必须将该项目推到他们自己的本地仓库, 然后在这个本地分支上修改/ 添加模块, 然后推回主分支 。

那么,初次初次国家当您在本地存储库中将主项目 提前启动时, 两支分支中的两支分支将变成这样( ) 。 ( ) @ info: whatsthisA, BC是项目已完成的模块)

enter image description here

现在,你已经开始研究新模块(假设)D),当你们完成D您想要将模块推到主分支中, 但是同时发生的情况是, 您的队友之一开发了新模块E, F修改和修改C.
所以现在发生的事情是 您的本地存储库 缺乏项目最初进展的背后 从而推动您对主要分支的更改 可能导致冲突 并可能导致您的模块D发生故障。

enter image description here

为了避免此类问题,并与项目的最初进展平行工作,有两种方式:

1. Git Fetch-(吉特接驳-)这将下载所有对本地分支中不存在的源/主分支工程所做的更改。 并将等待 Git 合并命令应用您仓库或分支的更改 。

enter image description here

现在您可以仔细监视文件, 然后将其合并到仓库。 您也可以修改D因修改而需要时C.

enter image description here

2. Git Pull-(吉特拉拉) - (吉特拉拉)这将更新您的本地分支, 使用源/ 主分支, 即它实际上所做的是 Git Fetch 和 Git 的组合 。但这可能引发冲突, 因此建议使用Git Pull,

enter image description here