Installing and Using Git Source Control on Windows

Including integration with Visual Studio and GUI Extensions

In this blog post I'll show you how to install Git on Windows. Git is "a free and open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency". However, the idea of this post is not to explain what Git is (I'm presuming you've heard of it) but to share my experiences of installing it on Windows and to look at what graphical tools are available to make Git a bit more friendly to use in a graphical environment. In particular, I'll look at how it can be integrated with Visual Studio, the most popular IDE for Windows developers.

msysGit - Git for Windows

The first thing to do to get started with Git is to download the Windows version of Git which is known as msysGit (Git for Windows) which is hosted on Google Code. Instructions for installing msysGit are included on the Git Wiki. This can be simplified into the following steps:

  • Go to the msysGit Downloads page and select 'Full installer for official Git' (at time of writing this is Git-1.7.4-preview20110204.exe) and download it. It's free.
  • Start the installer and follow the instructions
  • That's it - it really is that simple!

Note: If you also want to install Git Extensions (see below) then you can download an all-in-one installer that makes this even easier. Currently this is GitExtensions222SetupComplete.msi. However, it might not come with the latest version of msysGit, so beware.

However, during install you will be asked some questions. Generally you can leave the defaults selected; however, it is a good idea to ensure you have the Windows Explorer integration options as these make using Git much simpler. So, when you see the following dialogue then tick the boxes that say 'Add Git Bash Here' and 'Add Git GUI Here':

msysGit Install on Windows

Basically these options let you right-click on a folder in Windows and open it with either the Git Bash command-line tool or the Git GUI graphical tool.

You will also see the following dialogue asking you about "Adjusting your path Environment". Generally you can leave this at the default option, which is "Run Git from Windows Command Prompt". This allows you to run Git from the standard Windows command prompt by adding Git to your environment path. If this worries you (and it shouldn't) then you can just select to use Git Bash only - this doesn't modify your path, but does force you to use a UNIX-style command line only.

Git Environment Options

You can compare the two command-line shells in the screenshots below to see the difference:

Git command line from Windows Command prompt

Git Windows Command Prompt

Git command line using Git Bash shell

Git Bash shell on Windows

Using the default install options you can use either. Just note that using the Git Bash shell requires you to use UNIX-style commands, such as ls instead of dir to list files.

Git GUI

Learning how to use Git from the command line is a useful process and it is worth knowing how to perform the basic commands. However, being a Windows user you probably would also like something a bit more graphical, right? OK, no problem because mysysGit caters for this by installing Git GUI, which is exactly what it says.

Git GUI on Windows

You can perform all the standard functions of Git using this simple graphical interface that sits on top of the Git shell. It's not the prettiest of applications, but does the job and is relatively intuitive to use. In particular, things like diffing files becomes a lot easier to perform using a full graphical interface.

Git Extensions

OK, so you've got Git succesfully installed on Windows and have played around with the command prompt and the basic GUI. But surely, you think, there must be other open-source tools around that integrate with Git? And you would be correct.

Perhaps the most useful and popular graphical tool for Git for Windows is the Git Extensions project (also hosted on Google Code). This is an entire suite of small applications that integrate together with Git to make it entirely feasible to never look at the command-line again. Like Git GUI it ain't a great looker, but it works very well and is very useful. Even if you snear at graphical tools, you should check this out because it makes many version control tasks a lot simpler to perform.

Git Extensions on Windows

The screenshot above shows the commit log for a sample project, including a graphical representation of the branches.

You can download Git Extensions here. Just select the latest stable release.

Git Source Control Provider for Visual Studio

OK, all these GUI tools are great, but what I bet you'd really like is some kind of integration with your favourite IDE, Visual Studio? Luckily this is now possible due to a new project called Git Source Control Provider hosted on Codeplex (it supports both VS 2008 and VS 2010).

In case you didn't know, Visual Studio has it's own Source Control API which can be hooked into by plug-ins (sorry, this isn't available in the Express versions). By default this usually uses Microsoft's own Team Foundation Server. However, this can be easily changed to use any source-control provider that has been installed. This is done by accessing the Tools > Options > Source Control menu in Visual Studio. Once Git Source Control Provider has been installed you will see this option:

Git Source Control Provider Visual Studio 2010

Once installed and selected you can then open a project that is under Git version control and you will see the status of your files in the Visual Studio solution explorer file-manager dialogue:

Git Source Control Visual Studio File-manager

The files with a padlock are committed; the files with a + sign are new (and not yet staged) and the files with a tick indicate they have been changed since the last commit.

One of the great things about this project is that it also integrates nicely with Git Extensions (just remember to install Extensions first).

Other Git Tools

Of course there are other Git-related tools available for Windows. These include Tortoise Git (a port of TortoiseSVN for Git) and Gource, a really cool visualisation tool. You might find some more at the official Git Tools page (but generally this lags).

Posted: 02 June 2011 | Bookmark: Permalink | Comments: Post Comment | Follow: RSS Feed | Bookmark and Share |
Tagged: , , | Topics: Technology_Internet | Social Tags: Git (software), TortoiseSVN, Command-line interface, Programming tool, Repo (Script), Comparison of revision control software, Computing, Computer programming, Software engineering | Industry Terms: graphical tool, graphical tools, cool visualisation tool, command-line tool, open-source tools | Organisations: Google, the Express, Microsoft | People: Git Tools

Post a Comment

Please fill the form in below if you wish to add a comment:
Gravatar

Please don't post raw HTML - use editor above - otherwise you will get an error.