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 的性质。 您有远程和本地分支( 不一定相同 ) 。 与其他源控制系统相比, 这可能会有点令人困惑 。

通常当您检出远程时,会创建本地副本,跟踪远程。

gitreach 将会与远程分支合作并更新您的信息 。

实际上,如果其他SWES同一个部门工作,就属于这种情况,而小型项目----一个部门----一个项目设想方案的情况很少。

您对本地分支的工作仍然完好无损 。 为了将更改带回您的本地分支, 您必须合并/ 重订远程分支的更改 。

git拉动正好就是这两个步骤(即 -- -- rebase to rebase rebase 而不是合并)

如果您的本地历史和远程历史有冲突, 您将被迫在一小块按键发布您的更改时进行合并 。

因此,这真正取决于你的工作环境的性质和使用经验。

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

                                         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 抓取时会检索远程分支, 这样您就可以将 diff 和当前分支合并。 git 抓取时会在当前分支跟踪的远程条纹上抓取, 然后合并结果 。 您可以使用 git 抓取时查看远程分支是否有更新, 而不必将其与您的本地分支合并 。

初学者的简单图形化代表,

在这里,

git pull  

将会从仓库获取代码 并重新基础与您的本地... 在git拉动中,有 可能性创造新的承诺。

但是在,

git 获取 git 获取

将会从存储库获取代码, 我们需要使用 Git 重新基准来手动重标

eg: 我要从服务器主机取回它, 并在本地主机重标 。

1) git pull( 重基将自动完成) :

git pull origin master

这里的起源是您的远程回购主人 您的分支是您的远程回购主人

2) git 获取( 需要手动重标) :

git fetch origin master

它会从源代码中获取服务器更改。 它会位于本地, 直到您自己重新定位它。 我们需要通过检查代码手动来修正冲突 。

git rebase origin/master

这将会将代码重设为本地代码。 在确保您在正确的分支之前。

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