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

时光怂恿深爱的人放手 提交于 2020-03-17 10:05:23

问题


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 from remote branch

git rebase origin branch - makes conflicts


回答1:


git rebase <upstream> <branch>

is equal to

git checkout <branch>
git rebase <upstream>

By default <branch> is HEAD.

[1] https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html




回答2:


@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

then, your branch is updated to newest commits.




回答3:


The last step should be: git rebase origin/master



来源:https://stackoverflow.com/questions/29164321/git-difference-git-rebase-origin-branch-vs-git-rebase-origin-branch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!