I saw a neat Git alias for viewing your Git history on Git Immersion. I thought I’d share not only the alias, but how to use the new Git include function so you can add the alias from a source control-hosted version of your .dotfiles!
Which when you run this against the Jekyll repo, it gives us:
1 2 3 4 5 6 7 8 9
This is pretty nice as it is. But I thought I’d pimp it up a little bit by adding some of the color tags into the format. You set a color by including the %C option in your format, specifying a color, and %Creset when you want the color to end.
Applied to the original alias, we get this:
Cool, so we now have a nice shiny Git history command. But it’s pretty ugly having to type this everytime. We could add this to our Bash aliases in our .dotfiles, but under Git 1.7.10 released in April we can now use the includes process to directly add it to our Git config.
First, find the right .gitconfig file that you want to configure. The global .gitconfig file lives in ~/.gitconfig, but you could easily apply this to a specific repo’s .gitconfig file.
Add this to your .gitconfig file:
Add this to your .gitignore file:
My .dotfiles are stored in my personal Dropbox, so I navigate over to my .dotfiles folder and add this to a new .gitaliasconfig file there.
Back in your ~folder, create a symbolic link to your new .gitaliasconfig.
And just like that you can run
git hist and see your new pretty output, with your new alias stored in your .dotfiles config. If you really wanted to get fancy, you could move your config and ignore file to your .dotfiles store and get it all symbolically linked.
You could also use this to move your GitHub config to a private file, or any other specific git configuration you do.