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


当前回答

获取获取

git 获取实际上只从远程仓库下载新数据 - 但它没有将任何新数据整合到您的工作文件中。 获取对于获取远程仓库中发生的所有事物的新视图来说是件好事。 由于它具有“ 无害” 的性质, 您可以放心: 获取永远不会操作、 破坏或破坏任何东西 。

拉,拉,拉,拉

相比之下, git pull 用于不同的目的: 以远程服务器的最新更改更新您当前的 HEAD 分支。 这意味着不仅下载新数据, 还会直接将其整合到您当前的工作副本文件中 。

其他回答

git pull = git fetch + git merge 

Git pull 和 Git fick 之间唯一的区别是:

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

git 只从远程分支获取从远程分支获取的抓取, 但不会合并

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

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

git fetch
git diff ...origin

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

我想用视觉来描述这些事情。也许其他开发商也想看,所以我还要补充一下。我不完全确定这一切是否都正确,所以如果你发现任何错误,请评论。

                                         LOCAL SYSTEM
                  . =====================================================    
================= . =================  ===================  =============
REMOTE REPOSITORY . REMOTE REPOSITORY  LOCAL REPOSITORY     WORKING COPY
(ORIGIN)          . (CACHED)           
for example,      . mirror of the      
a github repo.    . remote repo
Can also be       .
multiple repo's   .
                  .
                  .
FETCH  *------------------>*
Your local cache of the remote is updated with the origin (or multiple
external sources, that is git's distributed nature)
                  .
PULL   *-------------------------------------------------------->*
changes are merged directly into your local copy. when conflicts occur, 
you are asked for decisions.
                  .
COMMIT            .                             *<---------------*
When coming from, for example, subversion, you might think that a commit
will update the origin. In git, a commit is only done to your local repo.
                  .
PUSH   *<---------------------------------------*
Synchronizes your changes back into the origin.

拥有远程镜像的一些主要优点是:

性能(通过所有承诺和信息,而不试图通过网络挤压它) 有关您本地回购状态的反馈(例如,我使用阿特拉斯西安的源树树枝,这给了我一个灯泡,显示我是否比来源提前或落后。这个信息可以用GIT FETCH来更新 ) 。

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

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