GIT … Lighten up a Bit

15 / Feb / 2011 by Manoj Mohan 0 comments

Hello there ..

Writing my first blog , I am still amazed by the effectiveness of working with Git . No matter how many times you mess up.. you can  still end up with a Clean Working directory. (Believe me .. 😉  ) .  I have also heard about the frustrating merge situations people have been in .. but I guess it has more to do with working systematically rather than with Git itself .

The one thing you can do to make life a bit more easy on git is brighten up the environment. A plain white/black color combo for a terminal can make it difficult to track large number of line additions such as in git diff (even though it is represented by a +/- sign .. we can still make it look better).

So the one thing we can do is play around with it and make it much more lively by adding some color.

First things first  … Adding Some color .Adding color to your command output can be as simple as something like

git config –global color.diff auto

This basically sets up a git config file with a color property in diff set to auto. Thats it .. simply enter git diff and viola …

Kodachrome is back 😀

Anytime you want to remove it simply put in

git  config –global color.diff false ..

Similarly one can do the same with status and branch outputs with

git config –global color.status auto

git config –global color.branch auto

You can also enter your information with

git config –global user.name  “Manoj”

git config –global user.email “manoj@intelligrape.com “

Now these files get added to your Git config file instantly but you can also separately go into your Git config file and add these entries ..  Just type   ~/vim .gitconfig

The file now would look something like this –

[color]
diff = auto
status = auto
branch = auto
log = auto
You can further modify it to look something like
[color “status”]
added = yellow
changed = green
untracked = cyan
Now once we have gotten into the Config file .. we might as well use the file to define some aliases .. Yes the same things that we inserted into our .bashrc files but the only thing is the aliases here would be git commands only. This not only removes the clutter in your .bashrc file but also provides a singular space to store your git aliases.
An alias in the config file would be something like
[alias]
psh = push origin master
pu = pull origin master

Now if you’ve had problems with the git merge tool being a tad bit simplistic .. you could go in for something like a Meld that gives you a efficient and powerful Linux GUI.   Just install it and specify something like

git config –global merge.tool meld

Thats all you need to use Meld .
Cheers

Manoj Mohan

FOUND THIS USEFUL? SHARE IT

Tag -

git VCS

Leave a Reply

Your email address will not be published. Required fields are marked *