TL;DR: Merge branch with latest
master
:git fetch && git merge origin/master
Given branches feature
and master
:
git branch
* feature
master
Merging master
into your feature
branch can be tedious:
git checkout master &&
git pull &&
git checkout feature &&
git merge master
Luckily, there’s a solution without having to checkout another branch:
git fetch &&
git merge origin/master
This means you can rebase your branch with master
:
git fetch &&
git rebase origin/master
Rebase rewinds and replays your commits on top of HEAD
, which requires a force push if you’ve pushed your branch to remote:
git push -f