Git pull 和 Git fick 之间有什么区别?


当前回答

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" ,因为有人一直在标记 一些文章在这里。

其他回答

我也为此挣扎过。事实上,我来到这里时,用谷歌搜索了完全相同的问题。阅读了所有这些答案,终于在我脑海中画出了一张图片,我决定试着从下面看2个储存库和1个沙箱的状况,以及一段时间以来在看它们的版本时所采取的行动。这就是我所想出来的。如果我在任何地方搞砸了,请纠正我。

三个邮箱有一个接听器:

---------------------     -----------------------     -----------------------
- Remote Repo       -     - Remote Repo         -     - Remote Repo         -
-                   -     - gets pushed         -     -                     -
- @ R01             -     - @ R02               -     - @ R02               -
---------------------     -----------------------     -----------------------

---------------------     -----------------------     -----------------------
- Local Repo        -     - Local Repo          -     - Local Repo          -
- pull              -     -                     -     - fetch               -
- @ R01             -     - @ R01               -     - @ R02               -
---------------------     -----------------------     -----------------------

---------------------     -----------------------     -----------------------
- Local Sandbox     -     - Local Sandbox       -     - Local Sandbox       -
- Checkout          -     - new work done       -     -                     -
- @ R01             -     - @ R01+              -     - @R01+               -
---------------------     -----------------------     -----------------------

三号邮局拉一拉一拉

---------------------     -----------------------     -----------------------
- Remote Repo       -     - Remote Repo         -     - Remote Repo         -
-                   -     - gets pushed         -     -                     -
- @ R01             -     - @ R02               -     - @ R02               -
---------------------     -----------------------     -----------------------

---------------------     -----------------------     -----------------------
- Local Repo        -     - Local Repo          -     - Local Repo          -
- pull              -     -                     -     - pull                -
- @ R01             -     - @ R01               -     - @ R02               -
---------------------     -----------------------     -----------------------

---------------------     -----------------------     -----------------------
- Local Sandbox     -     - Local Sandbox       -     - Local Sandbox       -
- Checkout          -     - new work done       -     - merged with R02     -
- @ R01             -     - @ R01+              -     - @R02+               -
---------------------     -----------------------     -----------------------

这帮助我理解了为什么买东西很重要。

git pull = = (获取 Git + git 合并)

git refick 不改变本地分支 。

如果您已经拥有一个本地仓库, 并且为所要的工程设置了远程设置, 您可以使用 git 抓取 。 ... Fetch 不改变本地分支 。 因此您需要将远程分支与本地分支合并, 以便从 Github 中引入新获取的更改 。

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

                                         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 FETCH来更新 ) 。

git 将代码从远程服务器拖动到您本地仓库的跟踪分支。 如果您的远程代码被命名为源代码( 默认) , 这些分支将位于源代码/ 内, 例如源代码/ 源代码/ 主管、 源代码/ mybranch-123 等 。 这些不是您当前的分支, 它们是服务器上这些分支的本地副本 。

git pull 进行 git 抓取, 但也同时将代码从跟踪分支合并到您当前本地版本的分支中。 如果您还没有准备好修改, 请先拨入 。

这种交互式图形表达方式非常有助于低估数据:http://ndpsoftware.com/git-cheatesheet.html。

git 获取从远程到本地仓库的更改时只“ 下載 ” 。 git 下载这些更改并将其合并到当前的分支中。 “ 在默认模式中, git 拖动是 Git 获取的简称, 然后是 Git 合并 FETCH_HEAD 。 ”