Save GIT branch name in Terminal: You want to see the branch name on the branch which are working on.

I had faced a problem where accidentally, i changed the origin/master codes which caused too many code conflict issues within the team. It was a shame and prickly situations within the team.

Solution :


  1. Go to your MAC Terminal.
  2. Type $ vi ~/.bash_profile.
  3. Enter this code
parse_git_branch() {
 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
  1. Now press "escape button,:(colon),w(save),q(quit),!" to come out of the editor.
  2. Type source ~/.bash_profile