Helpful Git Commands
I assume pretty everyone is using git these days for source code control. Here are a list of pretty useful utilities that make git more pleasant to use.
Note: I didn’t create any of these. They’re mostly things I picked up from working at Twitter
Add the branch name to your terminal prompt
When in a repository directory, show the name of the currently checked out Git branch in the prompt. Requirements Mac…martinfitzpatrick.name
This simple set commands in your bash profile will automatically display your current branch name.
Before we finish this chapter on basic Git, there's just one little tip that can make your Git experience simpler…git-scm.com
It gets annoying after a while to have to type “git checkout” all the time. “git co” is easier.
Git Branch Name Autocomplete
In bash in Mac OS X, you can use [TAB] to autocomplete file paths. Wouldn't if be nice if you could do the same with…code-worrier.com
This utility makes switching branches more pleasant. Simply type “git co xx” and hit tab to get a list of branch names that match “xx”.
Putting it all together in a .bash_profile…
# Git branch in prompt.
git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/ (\1)/’
export PS1=”\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ “
# Add git auto completion to command line
if [ -f ~/.git-completion.bash ]; then