git-fetch - git pull rebase用法 - git pull "和 "git fetch "的区别是什么?

Git version control / git / version-control / git-pull

git pullgit fetch 有什么区别?

Jonathan Leffler



Answer #1

我喜欢有一些直观的表现来把握这些东西。也许其他开发者也想看到,所以这是我的补充。我并不能完全确定都是正确的,如果发现有什么错误,请大家评论。

                                         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.