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


当前回答

git pull = = (获取 Git + git 合并)

git refick 不改变本地分支 。

如果您已经拥有一个本地仓库, 并且为所要的工程设置了远程设置, 您可以使用 git 抓取 。 ... Fetch 不改变本地分支 。 因此您需要将远程分支与本地分支合并, 以便从 Github 中引入新获取的更改 。

其他回答

我们简单地说:

git pull == git fetch + git merge

如果您运行 Git 调用, 您不需要将数据合并到本地 。 如果您运行 Git 抓取, 这意味着您必须运行 Git 合并才能将最新代码获取到本地机器 。 否则, 本地的机器代码不会在不合并的情况下被更改 。

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

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 Pull -- rebase

以上命令是我生命中最有用的命令 挽救了很多时间

在将您的新承诺推进到服务器之前, 请尝试此命令, 它会自动同步最新的服务器更改( 加上一个抓取 + 合并) , 并将您的承诺放在 Git 日志的顶部 。 无需担心手动拉动/ 合并 。

详情见:http://gitolite.com/git-pull-rebase

Git使用两个命令从远程到本地获取最新版本的分支 :

git 获取 : Git 会从远程获取最新版本到本地版本, 但不会自动合并 。 git 获取来源母版 master git log -p master. 来源/ master git 合并来源/ master 。 上面的命令意味着从远程下载主分支的最新版本, 从原始到来源母分支。 然后比较本地主分支和源母母分支。 最后, 合并 。 git pull : Git 会从远程获取最新版本并合并到本地 。 git pull 源母版 。 上面的命令相当于 git 获取和 git 合并 。 在实践中, git 获取可能更安全一些, 因为合并前我们可以看到这些修改并决定是否合并 。

这种交互式图形表达方式非常有助于低估数据:http://ndpsoftware.com/git-cheatesheet.html。

git 获取从远程到本地仓库的更改时只“ 下載 ” 。 git 下载这些更改并将其合并到当前的分支中。 “ 在默认模式中, git 拖动是 Git 获取的简称, 然后是 Git 合并 FETCH_HEAD 。 ”