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


当前回答

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

git fetch
git diff ...origin

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

其他回答

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

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

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

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

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 fetch将检索远程分支,以便您能够git diffgit merge它们与当前分支一起存在。git pull将运行当前分支所跟踪的远程条格获取,然后合并结果。您可以使用git fetch查看是否对远程分支有任何更新,而不必将其与您的本地分支合并。

初学者的简单图形化代表,

enter image description here

在这里,

git pull  

将会从仓库获取代码 并重新基础与您的本地... 在git拉动中,有 可能性创造新的承诺。

但是在,

git 获取 git 获取

将会从存储库获取代码, 我们需要通过使用git rebase

eg: 我要从服务器主机取回它, 并在本地主机重标 。

1) git pull( 重基将自动完成) :

git pull origin master

在这里来源来源是你的远程回寄师父您的分支

2) git 获取( 需要手动重标) :

git fetch origin master

它会从源代码中获取服务器更改。 它会位于本地, 直到您自己重新定位它。 我们需要通过检查代码手动来修正冲突 。

git rebase origin/master

这将会将代码重设为本地代码。 在确保您在正确的分支之前。

我想用视觉来描述这些事情。也许其他开发商也想看,所以我还要补充一下。我不完全确定这一切是否都正确,所以如果你发现任何错误,请评论。

                                         LOCAL SYSTEM
                  . =====================================================    
================= . =================  ===================  =============
REMOTE REPOSITORY . REMOTE REPOSITORY  LOCAL REPOSITORY     WORKING COPY
(ORIGIN)          . (CACHED)           
for example,      . mirror of the      
a github repo.    . remote repo
Can also be       .
multiple repo's   .
                  .
                  .
FETCH  *------------------>*
Your local cache of the remote is updated with the origin (or multiple
external sources, that is git's distributed nature)
                  .
PULL   *-------------------------------------------------------->*
changes are merged directly into your local copy. when conflicts occur, 
you are asked for decisions.
                  .
COMMIT            .                             *<---------------*
When coming from, for example, subversion, you might think that a commit
will update the origin. In git, a commit is only done to your local repo.
                  .
PUSH   *<---------------------------------------*
Synchronizes your changes back into the origin.

拥有远程镜像的一些主要优点是:

  • 业绩 业绩业绩 业绩业绩(在不试图通过网络挤压所有承诺和信息的情况下标注所有承诺和信息)
  • 反馈反馈反馈反馈反馈有关您所在的本地回收站的状况( 例如, 我使用阿特拉斯斯的源树树, 这将给我一个灯泡, 显示我是否承诺提前或落后于来源 。 这个信息可以用 GIT Fitch 来更新 ) 。