I planned to do a series on Git for a while. Then I thought maybe it had all been said already, so what’s the point?

Then Phil Haack moved to Github, and I realized that a lot of .NET Developers were still completely oblivious to the existence of Git (or any DVCS), so I thought about it again.

Then Phil Haack got you guys up to speed, so I went back to assuming it’s all been said.

Over the past few days, I’ve realized that there are bits and pieces spread around the internet, but I haven’t seen anyone do comprehensive posts that put it all together the way I like it. I was able to share some tricks, tips, and tools with several different people this week that have inspired me to take a crack at this, so here it comes.

Image used under Creative Commons Attribution License: http://www.flickr.com/photos/selago/73410200

Spoon-feeding

I am using this image and this terminology for two reasons. The first is that I am going to try to spoon-feed this to you so that you'll be up and running quickly and smoothly. The other is - I've had this discussion several times recently - I hope we can start to turn the .NET community away from a certain horrible stereotype (but that's for another post).

Note: what I’m sharing will obviously be my own preferred way of working with Git. You can (and should) use this only as a starting point. Then. continue to explore, evaluate, and think for yourself about how it can work best for you.

Also note: this post will only cover the installation of Git and the basic tools I use alongside of it. There will be follow-ups to cover more advanced tools, what Git is, how it differs from centralized source control like TFS and SVN, best practices, branching strategies, etc.

Step 1: Console2

Scott Hanselman put together a great post about configuring Console2 to take your command line to the next level. I recommend that you read it (I think I applied every setting he mentioned), but here are the settings I find most important:
  • Kill menu bar, status bar, and toolbar
  • Drop the alpha to 40
  • Set Ctrl+V for paste
  • Three tab types
    • Ctrl+F1 opens a Console tab (default)
    • Ctrl+F2 opens a Git bash (we'll add this in a bit)
    • Ctrl+F3 opens a Powershell tab (see Hanselman's post above)
image

Beautiful - notice that the transparency will allow you to read instructions while executing the commands you’re reading about. Keep this in mind when you get to step 4.

One more thing to be aware of -  I often go ahead and run this app as an Administrator, especially when I’m engaging in tasks that are patently “setup.” Keep in mind that some of what we do from the command line might require elevation.

Step 2: msysgit

This can't be easier. Go get the full installer for official Git for Windows from Google Code and run it. You should be able to take all the defaults except for one thing: add Git to your path by choosing the middle option on this screen.

image

Step 3: Console Tab for Git Bash

Back in Console2, add a new tab type for the Git Bash. I use the same icon and shell that the Git Bash shortcut on your desktop or start menu would use:

icon = C:\Program Files (x86)\Git\etc\git.ico
shell = C:\Windows\SysWOW64\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login -i"

Note that I also set a startup dir. All my git repositories will live here. We’ll get to those later. I set the same startup dir for my Powershell tab, but this is entirely up to you (you could use Ctrl+F4 to use a GitPowershell tab that launches powershell with that startup dir!)

image

Step 4: Verify the Install

So, Ctrl+F2 (or F3, or whatever tab type your Git Bash is). From the Git Bash run the following commands; I've added (verbose commentary).

mkdir demo
cd demo
git init
touch foo.txt
git add .
git commit  - m "Just foo"

verify git install

Easy peasy; you’re now using Git!

What's Next?

There are some additional tools and options that I'll introduce in the next post, and then we'll begin learning what Git really is and why you should care.

This post originally appeared on The DevStop.