54

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

svlasov
  • 9,923
  • 2
  • 38
  • 39
Adam
  • 1,779
  • 2
  • 15
  • 14

3 Answers3

72

@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.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Xiongmin LIN
  • 1,178
  • 11
  • 9
52
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

Thong Kuah
  • 3,263
  • 2
  • 19
  • 29
svlasov
  • 9,923
  • 2
  • 38
  • 39
15

The last step should be: git rebase origin/master

veben
  • 19,637
  • 14
  • 60
  • 80
zhu sheng
  • 151
  • 1
  • 3