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


当前回答

此图形可能有用 。 git pull 基本上等于 Git 获取然后 git 合并

其他回答

我也为此挣扎过。事实上,我来到这里时,用谷歌搜索了完全相同的问题。阅读了所有这些答案,终于在我脑海中画出了一张图片,我决定试着从下面看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 - 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 pull 基本上等于 Git 获取然后 git 合并

以下是Oliver Steele的画面,

我们简单地说:

git pull == git fetch + git merge

如果您运行 Git 调用, 您不需要将数据合并到本地 。 如果您运行 Git 抓取, 这意味着您必须运行 Git 合并才能将最新代码获取到本地机器 。 否则, 本地的机器代码不会在不合并的情况下被更改 。

所以在 Git Gui 中, 当您获取时, 您必须合并数据 。 获取本身不会在本地修改代码 。 您可以检查当您通过一次获取并查看来更新代码时, 是否更新了代码; 代码不会改变 。 然后您将合并... 您将会看到修改后的代码 。