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


当前回答

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

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

其他回答

之间唯一的差别git pullgit fetch是:

git pull从远程分支拉出并合并。

git fetch仅从远程分支获取取取, 但它不合并

i. e. git pull = git 获取 + git 合并...

所有分支都存放在.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 拉命令实际上是一个shortcut用于git 获取 git 获取排 排 排 排 排 排 排 排 紧 排 排git 合并git 重新基数取决于您的配置配置命令。 您可以配置您的 Git 仓库, 这样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" ,因为有人一直在标记 一些文章在这里。