refactor code to get current the git branch name

reffered http://qiita.com/sugyan/items/83e060e895fa8ef2038c