简体   繁体   English

git pull远程分支V / S git merge远程/分支V / S git rebase远程/分支

[英]git pull remote branch V/S git merge remote/branch V/S git rebase remote/branch

Consider my forked repo is mapped with the remote origin and the parent repo mapped to upstream . 考虑我的分叉存储库已映射到远程origin ,而父存储库已映射到upstream

Seems like, all the 3 commands below can be used to keep the master branch of origin , up to date with the master branch of upstream . 似乎,以下所有3条命令都可用于保持origin master分支的最新状态,使其与upstreammaster分支保持最新。

git pull upstream master

git merge upstream/master

git rebase upstream/master

Please help me understand if there are any differences between these three commands. 请帮助我了解这三个命令之间是否有任何区别。

The output of merge and pull is the same in the sense that changes from the merged branch is applied on top of current commits in your current branch. 在将合并分支的更改应用于当前分支中当前提交的意义上,merge和pull的输出是相同的。

Before pull /merge 拉/合并之前

  A---B---C master on origin
 /
D---E---F---G master

After

  A---B---C origin/master
 /         \
D---E---F---G---H master

The output of rebase is reverse of pull. rebase的输出是pull的反向。 All the new commits from the point the current branch is created is shelved. 从当前分支创建点开始的所有新提交都被搁置。 The commits from the remote branch is applied and then the local commits are applied. 应用来自远程分支的提交,然后应用本地提交。 So compared to pull the local commits are at the end of commits of remote. 因此,与拉本地提交相比,在远程提交的结尾。

     A---B---C topic
     /
D---E---F---G master

After rebase command 变基命令后

              A'--B'--C' topic
             /
D---E---F---G master

Source - https://git-scm.com/docs/git-rebase 来源-https: //git-scm.com/docs/git-rebase

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM