Git rebase VS git merge

Git merge

git checkout -b newbranch #use this one if you don't have the newbranch before
git checkout newbranch
git merge origin/master
git push origin newbranch

Git rebase

git checkout newbranch
git fetch
git rebase origin/master
git push origin newbranch

The difference between merge and rebase

It can be shown from the nice illustration below[2].

Image source [2]

Rebase master and force push to feature branch

A nice discussion can be found in [3].

Reference

[1]https://intellipaat.com/community/11548/update-git-branches-from-master-git-update-branch-from-master

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store