You already use git pull, and you heard about the git rebase, but you never used it before ? Here is a short explanation.

Pre-requisite : what is git pull ?

git pull = git fetch & git merge

git fetch can be done with rebase or merge, it doesn’t matter. You can learn more on git fetch here. The interesting question here is :

What is the difference between git merge and git rebase ?

Note :
You can type git pull --rebase = git fetch & git rebase

What is git rebase

So git rebase is an alternative to git merge

Instead of creating a new commit that combines the two branches, it moves the commits of the first branch on top of the other.
Peter (stackoverflow).

Rebasing : Pros & Cons

Pros:

Cons:

When to use rebasing according to the atlassian

And that’s all you really need to know to start rebasing your branches. If you would prefer a clean, linear history free of unnecessary merge commits, you should reach for git rebase instead of git merge when integrating changes from another branch.

On the other hand, if you want to preserve the complete history of your project and avoid the risk of re-writing public commits, you can stick with git merge. Either option is perfectly valid, but at least now you have the option of leveraging the benefits of git rebase.

So when rebasing a feature branch (that you, and only you are working on) on top of a public master branch, it looks like :

git checkout feature
git rebase master

Rule of thumb

Don’t rebase if you already are on the master branch. It’s reserved to feature branches

Reference: