-3

What is the difference between git rebase origin/master and git pull --rebase origin master ?

What should I prefer when I finished working on feature and want to rebase? Now I do

  1. git rebase origin master
  2. git push --force

Is this good workflow? If not, please recommend something better.

vakio
  • 3,134
  • 1
  • 22
  • 46
Monarch
  • 43
  • 1
  • 5
  • `git pull --rebase` will rebase the current branch onto whatever's on the tracking branch. If you're working on your own feature branch, and nobody else is pushing to it, it won't do anything. – jonrsharpe Aug 11 '21 at 08:50
  • sorry for ambiguity, I mean git pull --rebase origin master – Monarch Aug 11 '21 at 08:52
  • 1
    I guess one difference would be that `git rebase origin/master` uses the local copy, which might be out of date with the remote, whereas `git pull ...` will include a fetch. – jonrsharpe Aug 11 '21 at 08:57
  • https://stackoverflow.com/search?q=%5Bgit%5D+difference+between+%E2%80%9Cgit+rebase%E2%80%9D+and+%E2%80%9Cgit+pull+--rebase%E2%80%9D – phd Aug 11 '21 at 13:21

1 Answers1

2

pull includes a fetch meaning you will get the latest master. rebase origin/master, will just get whatever origin was the last time you did a fetch. So that is not guaranteed to be the latest.

What should I prefer when I finished working on feature and want to rebase?

The pull is slightly better in your case because you will get the latest. But in the end it doesn't really matter, because you will have to catch up to master later anyway when you want to push your code there

vakio
  • 3,134
  • 1
  • 22
  • 46