Git comes with a handy shell script that could be used to display the actual branch name within the bash. This could protect you from doing the right stuff with the wrong branch.
If you've installed git via a package manager the script itself is installed to "/etc/bashcompletion.d/git" and all you have to do is to add the following lines either to your local bashprofile or the global version of your system:
# Show current Git branch on bash prompt source /etc/bash_completion.d/git PS1="[\[\033[32m\]\w]\[\033[0m\]\$(__git_ps1)\n\[\033[1;36m\]\u\[\033[32m\]$ \[\033[0m\]"
After a relogon your PS1 should be extended as soon as you are in directory which is under version control by git. This will look similar to this:
[/home/hero/best_project] (master) hero$
On Mac OSX
If you have installed the Git version that is provided by Apple you can add the following to your ~/.bash_profile:
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh PS1="[\[\033[32m\]\w]\[\033[0m\]\$(__git_ps1)\n\[\033[1;36m\]\u\[\033[32m\]$ \[\ \033[0m\]"