当前位置:   article > 正文

Git之git rebase master和git rebase origin/master的区别

git rebase origin/master

The different is to rebase on your local master, or the one of origin. It's likely that your local master is behind origin/master, but it could be also forward or even has different histories (not recommend)

If your master is the same as origin/master, it doesn't matter which one to use.

We rebase (and branch) from origin/master so we don't have to update our local master. (no need to do git pull on the local master branch).

If you rebase on local master, you could do:

  1. git checkout master // 切换到本地master分支
  2. git pull origin master // git pull <remoteName> <branchName>, 拉取远程master分支并更新本地
  3. git checkout branchA // 切换到本地branchA分支
  4. git rebase master // 变基,将本地master最新的代码合进本地的branchA分支。完成后,本地的branchA分支是最新的

if you rebase on origin/master, you could do:

  1. git fetch // download objects and refs from another repository
  2. git rebase origin/master // 将远端master最新的代码合进本地的branchA分支。

so a lot shorter.

For even shorter, you could also use "pulled rebase", that one is nicely to combine with the "origin rebase":

git pull origin master --rebase

No need to fetch then.

参考文献:https://stackoverflow.com/questions/45920951/when-use-rebase-master-or-origin-master

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号