Keep a clean, linear history.
Ideally suited for high-performing teams and individual feature branches. Keeps history linear and clean.
$ git checkout -b jz-my-branch
# make my changes
$ git push origin jz-my-branch
# create a Merge Request
# three days go by and now my branch is out of sync with master
$ git fetch origin master
$ git rebase origin/master
$ git push --force origin jz-my-branch
Note: By rebasing, you only need to solve merge conflicts for newer commits. It provides a better experience.
# Clean up your branch (warning will delete everything not matching remote)
git fetch --prune origin
git reset --hard origin/master
git clean -f -d
# Setting your branch to exactly match the remote branch:
git fetch origin
git reset --hard origin/master