两者之间有什么区别?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" ,因为有人一直在标记 一些文章在这里。

其他回答

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

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

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

我们简单地说:

git pull == git fetch + git merge

如果你逃跑git pull中,您不需要将数据合并到本地数据。如果运行git fetch这意味着你必须跑git merge获取本地机器的最新代码。 否则, 本地机器代码不会在不合并的情况下被更改 。

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

Git 获取

帮助您从一个git repository。让我们假设你在一个团队中工作 使用GitFlow,其中团队在多个branches(特征). 与git fetch --all command您可以了解所有新的信息branchesrepository.

大部分git fetch用于git reset。例如,您想要将全部本地更改恢复到当前仓库状态。

git fetch --all // get known about latest updates
git reset --hard origin/[branch] // revert to current branch state

Git 拉着

此命令更新您branch与当前repository branch状态。让我们继续GitFlow多个特性branches原为mergeddevelop分支,当您想要为项目开发新特性时,您必须去开发branch并做一个git pull以获得当前状态develop branch

GitFlow 文档文档https://gist.github.com/peterdeweese/4251497

缩略git 拉命令实际上是一个shortcut用于git 获取 git 获取排 排 排 排 排 排 排 排 紧 排 排git 合并git 重新基数取决于您的配置配置命令。 您可以配置您的 Git 仓库, 这样git 拉是一个接驳物,然后是一个重置物。

git fetch从远程服务器将代码从远程服务器撤回到本地仓库的跟踪分支。如果您的远程服务器被命名origin然后,这些分支将居其中;origin/,例如,origin/master, origin/mybranch-123等等。这些不是你们的现树枝,而是你们的现树枝。当地当地服务器上那些分支的复制件

git pull是否为 a 的git fetch但当时并且,还有将跟踪分支的代码合并到您当前本地版本的该分支中。如果您尚未准备好进行该修改,只需git fetch头一次。