Git for Windows And .NET Developers – How To Install Git

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.

Advertisements

About David Ruttka

I've been "making computers do things" since I first saw King's Quest on a 286 PC in the mid-80's, but I turned it into a career just over a decade ago. While the majority of my experience has been on the Microsoft stack (C#, .NET, ASP.NET), I've recently been diving deeper into JavaScript and exploring the Ruby universe. Occasionally, I'll do a public speaking gig or write a blog post. When I'm not coding, I enjoy spending time with my family, watching hockey, and playing the occasional video game. You can also find me on Stack Overflow, Google Plus, and Twitter. Microsoft Certified Programming in HTML5 with JavaScript and CSS3 Specialist; MCPD Windows Developer 3.5
This entry was posted in Development and tagged , , , , , . Bookmark the permalink.

One Response to Git for Windows And .NET Developers – How To Install Git

  1. kcs says:

    Thank you for putting this all in one place, I prefer that too.

Thoughts?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s