Reputation: 1701
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
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