Green
Green

Reputation: 30815

How to do fetch and rebase?

git pull is just a:

The git pull command is actually a combination of two other commands, git fetch followed by git merge.

So I can manually do two commands:

# I'm on master branch now!

$ git fetch origin master

remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 5 (delta 4), reused 4 (delta 4), pack-reused 0
Unpacking objects: 100% (5/5), done.
From github.com:user/app
 * branch            master     -> FETCH_HEAD
   2b73030..58a1447  master     -> origin/master

$ git merge origin/master  // <= from 'origin/master'

As you can see, in a second command I merge origin/master into master.

But how to do it with rebase? I'm in doubt if origin/master is correct for rebase:

$ git fetch origin master
$ get rebase origin/master // <= is this correct? What is correct way?

Upvotes: 0

Views: 1685

Answers (1)

Jan Kr&#252;ger
Jan Kr&#252;ger

Reputation: 18530

Yes, that's exactly correct (though I'd simply git fetch or git fetch origin to have all of your local origin mirror updated, which also prevents issues with fairly old versions of Git).

However, you can also simply do git pull --rebase.

Upvotes: 3

Related Questions