Practical Web Programming

Thursday, December 19, 2013

git: Merge master to feature_branch Often to Minimize Conflicts

One of the best way to avoid conflicts (or large unmanageable conflicts) is to merge master often to develop or whatever feature branch you are working on. This way, you will integrate all the changes made to master (by other developers or you) to the current branch as you progress. Here's an easy way to do it:

$ git checkout feature_branch
$ git pull origin master

The first command makes sure you are on the right branch, and the second one fetches the changes in origin/master repo and merge into the current branch. Take note that if you omit origin master from the second command, it will try to fetch and merge origin/feature_branch - not what you want to do here.

Recent Post