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


当前回答

Git 获取

帮助您从 Git 仓库获取最新更新信息 。 假设您在一个使用 GitFlow 的团队中工作, 该团队在多个分支( 功能) 上工作 。 有了 Git 抓取 -- 所有的指令, 您都可以了解仓库中所有新的分支 。

多数情况下, git 抓取程序都与 git 重置一起使用。 例如, 您想要将全部本地更改恢复到当前仓库状态 。

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

Git 拉着

此命令以当前仓库分支状态更新您的分支处 。 让我们继续使用 GitFlow 。 多个特性分支已被合并来开发分支, 当您想要为项目开发新特性时, 您必须前往开发分支处, 并做一个 Git pull 以获取当前开发分支的状态

GitFlow 的文件 https://gist.github.com/peterdeweese/4251497

其他回答

用最简单的术语来说, git pull 是一个 Git 抓取, 然后是 git 合并 。


git 在 refs/ remotes/ <remote> / 下获取远程跟踪分支的更新。 此操作随时可以安全运行, 因为它不会在 refs/ head 下更改您的本地分支 。

git 拉动使当地的一个分支能够更新其远程版本,同时更新其他远程跟踪分支。

Git Pull 的 Git 文档 :

git pull 运行 git 获取带有给定参数的 Git 抓取, 然后根据配置选项或命令行旗帜, 将调用 git 重新基准或 Git 合并以调和不同的分支 。

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

git pull 进行 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 保有一份您自己的代码副本和远程仓库 。

命令 git 抓取时通过从远程仓库获取数据更新本地副本。 我们需要这个数据的原因是, 其他人可能对代码做了一些修改, 您想要不断更新自己 。

命令 Git 拖动将远程仓库的更改带到您保存您自己的代码的位置。 通常, git 拖动这样做的方式是先做一个“ git 抓取” , 将远程仓库的本地副本更新为最新版本, 然后将修改合并到您自己的代码仓库, 并有可能将您的工作副本合并到您自己的代码仓库中 。

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