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


当前回答

回报 :

谈到上述答案中的拉动和取回,我想分享一个有趣的把戏,

git Pull -- rebase

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

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

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

其他回答

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

git pull 进行 git 抓取, 但也同时将代码从跟踪分支合并到您当前本地版本的分支中。 如果您还没有准备好修改, 请先拨入 。

git pull = git fetch + git merge 

git 拉

它使用单一命令执行两个函数。

它会获取对远程分支的所有修改, 然后将这些修改合并到您的本地分支中。 您也可以通过 -- rebase 来修改拉动行为。 合并和重基准的区别可以在这里读取

git 获取 git 获取

Git 抓取仅能完成 Git pull 的一半工作。 它只是将远程更改带入您的本地回购, 但没有将其应用到分支中 。 您必须明确应用这些更改 。 这可以做如下操作 :

git fetch
git rebase origin/master
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 == git fetch + git merge

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

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