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


当前回答

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 合并...

您可以从远程仓库获取, 查看差异, 然后拉动或合并 。

这是被称作远程仓库的示例origin和支派,和支派,master跟踪远程分支origin/master:

git checkout master                                                  
git fetch                                        
git diff origin/master
git rebase origin master

所有分支都存放在.git/refs

所有地方分支机构都存放在.git/refs/heads

所有远程分支都存放在.git/refs/remotes

缩略git fetch命令下载 承诺, 文件, 和 refs 从远程仓库下载到您的本地 repo 。 抓取是您想要看到其他人正在做的工作时要做的事情 。

所以当你做git fetch全部文件、 承诺和 refs 都下载在

此目录.git/refs/remotes

您可以切换到这些分支以查看变化 。

另外,如果你愿意,你可以把它们合并起来。

git pull只需下载这些更改, 并将其合并到当前分支 。

示例示例示例示例

如果您想看远程分支的工作dev/jd/feature/auth,你只需要做

git fetch origin dev/jd/feature/auth

看到变化或工作进展做,

git checkout dev/jd/feature/auth

但如果您也想要获取它们并将其合并到当前分支,

git pull origin dev/jd/feature/auth

如果有的话git fetch origin branch_name,它将获取分支,现在您可以切换到您想要的分支,并看到变化。您的本地主子或其他本地分支不会受到影响。但您不会受到影响。git pull origin branch_name将获取分支, 并合并到当前分支 。

Git允许在较新的承诺之后适用按时间顺序排列的旧承诺。 因此,存放库之间转移承诺的行为分为两步:

  1. 正在从远程分支复制新承诺, 复制本地副本中的此远程分支 。

    (收回业务)master@remote >> remote/origin/master@local

  2. 整合对地方分支机构的新承诺

    (内购外业务)remote/origin/master@local >> master@local

第二步有两种方法,你可以:

  1. 在上一个共同祖先之后,将本地分支叉到叉口,并添加与本地仓库独特的承诺平行的新承诺,通过合并承诺最终完成,关闭叉口。
  2. 在上一个共同祖先后插入新承诺,并重新应用本地仓库独有的承诺。

git术语术语,第1步是git fetch,第2步是git mergegit rebase

git pullgit fetchgit merge

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

git fetch
git diff ...origin

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