Git merge master


TL;DR: Merge branch with latest master:

$ git fetch && git merge origin/master

Given git branches master and feature:

$ 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


If you enjoyed this post, please consider supporting this site!