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


当前回答

有时视觉表现会有所帮助。

其他回答

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

                                         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 pull 基本上等于 Git 获取然后 git 合并

有时视觉表现会有所帮助。

回报 :

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

git Pull -- rebase

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

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

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

获取获取

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

拉,拉,拉,拉

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