Back to all tips

Git Noob Tips

Rebase When Pulling Master

🗓️ Published: 5/6/2022

When pushing, your local branch must be ahead of the remote branch, otherwise, the push is rejected. This is called the "fast-forward rule". In the case of a feature branch, one can force-push, but one should never force-push to master.

So, always keep your local master ahead.

That is done by rebasing. When you want to update your master branch with the remote repo, and especially when you have local changes, do a rebase pull:

git pull --rebase origin master

Otherwise, a merge commit might be created on your local repo and you can never push to master again.

Discuss this tip on