git-fetch - Git - git pull」と「git fetch」の違いは何ですか?

GitHub / 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.