Another sip of code ?

Reminder - Git/diff - Add Some Colors to Diff

| Comments

I like diff. It’s a very usefull tool. But it comes by default only in black and white and it’s quite difficult to rapidly see the differences in the code.

Don’t worry the solution is very easy and is called colordiff !

First step, let’s install color diff : Since I am using Fedora, I use Yum to install, but colordiff should be in the repositories of you favorite linux distro.

sudo yum install colordiff

you can now use colordiff instead of diff to add some colors to your life.

Now to some even better stuff, let’s enable this into git !

For that you can use the easy and fast way with this command :

git config --global color.ui true

there is also another and more complicated way, by opening the .gitconfig file in your home directory (so ~/.gitconfig) and adding these lines :

        branch = auto
        diff = auto
        interactive = auto
        status = auto

And voilà, git now use colordiff instead of diff when you use the command git diff and that make your life more easy and I like when my life is more easy.

These two method are very similar, the first one enable the default automatic way to add color to git diff, the second one open a whole new level of customization where examples can be found on the git Cheat Sheet (see sources).

Sources: Git CookBook Git Cheat Sheet