-2

what is the difference between

  • git pull --rebase
  • git rebase origin/nameOfBranch

and when must use one over the other

cafce25
  • 15,907
  • 4
  • 25
  • 31

1 Answers1

2

The difference is that git pull does two things:

  • fetch and
  • merge (or rebase, since you give it the --rebase argument)

On the other hand, git rebase does only the rebase, not the fetch.

SebDieBln
  • 3,303
  • 1
  • 7
  • 21
  • if I type **git pull --rebase** does it mean I made **fetch+merge+rebase** (as pull is a combination of fetch and merge) ? – bohi tibuti Nov 24 '22 at 10:42
  • @bohitbti No, it does a rebase instead of a merge. – SebDieBln Nov 24 '22 at 10:43
  • in that case I should have used git rebase directly, no ? so which are the cases should I use 1) git pull 'only', 2) git rebase 'only', 3) git pull --rebase – bohi tibuti Nov 24 '22 at 10:52
  • @bohitbti That depends on whether you want to do the fetch or not. Remember that a fetch is the way to get new commits from the remote repository. `origin/nameOfBranch` is only changed by a fetch operation. A simple rebase will never move `origin/nameOfBranch`. – SebDieBln Nov 24 '22 at 11:20
  • I guess I must make a fetch before pushing my commit ? – bohi tibuti Nov 24 '22 at 11:57
  • what is the 'i' param added in some command – bohi tibuti Nov 24 '22 at 11:57
  • *I guess I must make a fetch before pushing my commit?* I would consider that best practice, but technically it is not required. – SebDieBln Nov 24 '22 at 17:18
  • *what is the 'i' param added in some command?* That is a new question ;-) – SebDieBln Nov 24 '22 at 17:19