Git Tricks


Add a splash of color to your git output

For those who grew up with DOS, you'll probably recall the delight when it become possible to color the terminal characters. This feature has long since been disabled: as more and more people prefer are using the GUI rather than the command line to do their work. However, it is still possible to turn those lovely colors back on, if you are so inclined. To do this, simply add the following line in %SystemDrive%\config.sys (or config.nt for older versions of NT):


That is it. After you're done reboot and tell git to use colors. It will now highlight important information for you. To enable this for all "colorable" git commands, issue the following:

  git config --global color.branch "always" 


Eliminate whitespace from a commit

Imagine your editor converted all spaces to tabs or tabs to spaces. You absolutely do not want to commit such a change. There will be no way to easily tell what you actually changed if every line of a file change a change. When this happens use git diff with the -w and/or -b options to create a patch that does not have your whitespace changes, reset the file you changed to match HEAD and apply your patch.

In Source Builds

Hiding build output from git status

Ensure that the only untracked files are files you want hidden from the output of git ignore. Then use:

git clean -ndfx | sed 's/^Would remove //' > .git/info/exclude

(Untested, based on an email from nwp. Try at your own risk.)