Git Pills – My personal Git environment on Windows

Working mostly as a C# developer, I usually spent my day on Windows. To easily replicate my default Git configuration across all the computer I work with, I created a tiny GitHub repository.

I’m a very bad typist. Every time I type a Git command on the Bash shell, I need at least two attempts to get on the command line what I want.
Fortunately there are Bash aliases, Git aliases and auto-correction; so now the only think I have to take care while typing are branch names :)

To easily move my environment from a PC to another, I created a GitHub repository to clone: GitEnvironment.
As you probably know, Git configuration has three different layers: system, user, and repository; cloning this repository you will obtain a default per-user configuration.
In Windows, the user configuration files are stored in C:\Users\<Username> folder, so the trick is to clone the repository in that folder:

At this point you will get there these files:

  • Bash profile files
    • .bash_profile, for Windows 7 and previous
    • .bashrc for Windows 8
  • Git config files
    • .gitconfig file
    • .gitconfig-vs2013

With Bash configuration files I was able to define an alias for the git command, considering that I type “gti” instead of “git” for 90% of times… You can then enrich your Bash profile wit other aliases and other configurations you like.
There are two different Bash configuration file because I discovered that in Windows 7 configurations are loaded form .bash_profile, while in Windows 8 the they are loaded from .bashrc; the content of files is the same.

Adopting a common per-user Git configuration instead, I’m able to replicate my aliases on all my Git boxes; the .gitconfig-vs2013 file is just a copy of the default .gitconfig file, where I set to use the diff and merge tools included in Visual Studio.

Feel free to fork my repository, make me pull requests and adjust your fork to fit your needs :)

Ciao,
Nando :)

4 thoughts on “Git Pills – My personal Git environment on Windows

  1. Thanks for sharing. I like to see how VS can be configured for diff/mergetool.

    I”m curious, why not give your own tech-stack some merit by using Powershell instead of bash? Posh-git makes this very enjoyable, I think. Here’s my Windows setup, perhaps a bit dated as I don’t often use it: http://blog.tfnico.com/2012/04/my-git-setup-on-windows.html – some updates here: http://blog.tfnico.com/2014/01/presenting-git-for-windows-again.html

    • Hey Thomas, glad to see you here :)
      Unfortunately PowerShell is out of my comfort-zone, I didn’t use it (my bad). This can be an opportunity to learn something about it; I heard about Posh-Git yet, but I never tried it; ok let me point a sticky note on my personal improvement kanban :)
      Thank you too for sharing your experience, I’m going to read your posts this weekend, I will leave with my thoughts there.

Leave a Reply

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