How to update feature branch from master in Git

If you want to update your git feature branch with the new changes from the master branch, you need to:

  1. Update master branch
  2. Merge or rebase the new changes

TL;DR: merging creates additional commit, rebasing rewrites history. Usually the team chooses the way to handle conflicts in repository so ask your colleagues first what your team approach is.

To merge

git checkout master
git pull
git checkout target_feature_branch
git merge master

To rebase

git pull --rebase origin target_feature_branch 
fix conflict and then → git add . 
git rebase --continue 
git push -f

Leave a Reply

Your email address will not be published. Required fields are marked *