Git之git rebase 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:

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

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

git fetch // download objects and refs from another repository

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

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值