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


当前回答

以下是Oliver Steele的画面,

其他回答

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

这是被称作起源的远程存储库和名为“跟踪远程分支来源/主管”的分支的分支的一个例子:

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

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

git fetch
git diff ...origin

见 git diff 关于双点... 和三点... 语法的文件。

所有分支都储存在.git/refs中。

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

所有远程分支都储存在.git/refs/remotes中。

git 获取命令下载承诺、 文件、 从远程仓库获取 refs 到您的本地 repo 。 获取是您想要看到其他人的工作内容时要做的事情 。

所以当您在 Git 获取所有文件、 承诺和 ref 时, 在

此目录. git/ refs/ remotes

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

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

git pull 只是下载这些修改, 并合并到当前分支 。

示例示例示例示例

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

git 获取源于 dev/jd/ feature/auth

看到变化或工作进展做,

git 检出 dev/jd/feature/auth

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

git 拉力源dev/jd/feature/auth

如果您选择了 Git 获取源代码分支_ name, 它将会获取分支, 现在您可以切换到您想要的分支, 并查看这些变化。 您的本地主子或其他本地分支不会受到影响 。 但 Git pull 源代码分支_ name 将会获取分支, 并同时合并到当前分支 。

此图形可能有用 。 git pull 基本上等于 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" ,因为有人一直在标记 一些文章在这里。