Register

Jan 2009 15

Making yourself comfortable with git in the terminal

If you’re cloning or forking Tracks from GitHub, you might be interested in some changes you can make to your .bashrc to make using git a bit more comfortable. Henrik over at The Pug Automatic posted this tip for putting both your current branch name on the command line, and also indicating whether you have any uncommitted changes in the branch. If your branch has uncommitted changes, it prints an asterisk after the branch name. This is incredibly helpful for seeing at a glance what state you are in, without having to issue the commands ‘git branch’ or ‘git status’. If you flit about between branches a lot, having the branch name at the command prompt can save you from a great deal of trouble.

You can grab Henrik’s code here, or use mine below. I just foraged around among the forks and the comments on this related post to get a version combining the best bits of them all, then I substituted in my existing command prompt. Enjoy!

3 Comments

works like a charm grin

I’m glad you took the best of the more than dozen forks of the original snippet and produced something short and sweet.

I made one minor change to it to make it more readable and maybe customizable for folks that want different colors:

http://gist.github.com/154793

You need to log in before you can post a comment. Please use the form at the top of the page to log in, or to register as a user.