Git: difference “git rebase origin/branch” VS “git rebase origin branch”

前端 未结 3 522
孤街浪徒
孤街浪徒 2021-02-05 05:03

Does anyone know what is the difference? Seems to me, it is the same. But when I run it, it didn\'t do the same thing:

git rebase origin/branch - ok rebases

3条回答
  •  攒了一身酷
    2021-02-05 05:40

    @Mar's answer is right and perfectly solved this question, just add one comment.

    if you want to rebase a branch based on remote master branch, git rebase origin/master is not enough, it will not get new commits directly from origin/master. You need to git fetch before 'git rebase origin/master'.

    or you can use another way to rebase a branch.

    1. switch to master git checkout master
    2. git pull origin master
    3. switch back to your own branch git checkout {your branch}
    4. git rebase origin/master

    then, your branch is updated to newest commits.

提交回复
热议问题