Friday, September 24, 2010

Git Update Master

As a git user, I used to work under feature branches, make changes and commit back to master at once. However sometime the master changes a lot and you have to pull changes from remote in master branch. Here's what I do to ease the messy branch switching...

current_branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
git checkout master
git pull
git checkout $current_branch