Pravin
Pravin

Reputation: 1701

What is the difference between the rebase in git pull --rebase and git rebase <branchname>?

I have been taught to rebase my the repo before starting my work on any branch. But I am confused in git pull --rebase and git rebase <branch> . What is the difference between the two?

Upvotes: 1

Views: 189

Answers (1)

Jonathan Wakely
Jonathan Wakely

Reputation: 171283

Exactly as the commands suggest, one does a pull and a rebase, and uses the current branch's default upstream. The other only does a rebase, and uses the specified branch (which is not necessarily the current branch's upstream).

This means the first one fetches all the new commits from upstream, then rolls back local commits, fast-forwards to the upstream head, then re-applies the local commits.

The second one doesn't fetch anything, it rebases the current branch on top of the specified branch without checking to see if that branch has been updated.

The git help rebase and git help pull documentation describes these pretty well, you should read them.

Upvotes: 2

Related Questions