Decentralized Revision Control Tooling on Windows

Today I’d like to take a few minutes to talk about setting up Git for your development projects on the Windows platform. I’ve long been a fan of Mercurial, because the installation process is easy, and the tooling is native to the Windows platform. While Git and Mercurial are very similar version control tools, GitHub appears to be a stronger community hub, compared to Mercurial hosting sites like CodePlex and Bitbucket, and it’s worthwhile getting familiar with it.

Mercurial Tooling

TortoiseHg Overlay IconsAs I stated before, Mercurial is very easy to install on Windows, and it doesn’t have any additional dependencies that you have to worry about manually installing. While Mercurial itself is a command line tool, there’s also a project called TortoiseHg that offers GUI screens to perform common source control tasks, including: commits, file adds/removes, branching, repository configuration, and so on. In addition, TortoiseHg enables some handy Windows Explorer integration, namely overlay icons and context-sensitive context menu tools!

What are overlay icons? They’re little icons that give you a representation of a file or folder’s status in the Mercurial repository, from Windows Explorer. This makes it super easy to determine if a file has: just been added, been changed, or is fully up-to-date, while you’re browsing around the filesystem.

When you install TortoiseHg, it also installs Mercurial for you automatically, so you don’t have to worry about separate downloads. It also adds hg.exe to your %PATH% environment variable, without any fuss, so all you have to do is install it, and you’re good to go! The TortoiseHg team is regularly releasing updates to it, along with updates to Mercurial itself, so if you’re a Mercurial user, then I would highly recommend you use this tool! They do a great job of clearly indicating the TortoiseHg version number, Mercurial version number, and the release date, so you can easily determine if you need to upgrade at any given point in time!

All in all, from an end user perspective, Mercurial and TortoiseHg get an 8/10! The only points I’d take off are because the GUI screens are a tad large and clunky. I think they could be designed to look a bit nicer, but from a functionality perspective, they’re great!

Git Tooling

msysgit - environment settingsThe Git tooling for Windows (not the official GitHub for Windows client) appears to be a little less mature, or perhaps just not as well packaged as Mercurial is. Git itself is a highly robust, and widely used, version control system, however.

One of the popular tools used by developers is called msysgit. This project brings Git command line functionality to the Windows platform. The drawbacks to this is that its installer is a little bit awkward and riddled with seemingly unnecessary options. It offers three different options to screw around with your %PATH% environment variable, and it also offers some sort of UNIX-like functionality through BASH, which I really don’t care about as a Windows user. I don’t even want to see anything about it. If I wanted BASH, I would install Cygwin, but even then, I just don’t care about BASH at all.

In addition to the environment variable configuration, msysgit setup also contains a configuration screen for how to handle CRLFs (carriage return line feeds). Honestly, I should not even have to see this screen, as a Windows user, during msysgit setup. The default should simply be to use the CRLFs that are in the source files, and don’t touch them. If I want to go in and change that functionality of Git later, there should be an option for it, but don’t bother me with it until then.

As for the packaging of msysgit, it appears to use a moderately robust installer mechanism, however I would recommend that they use the Windows Installer mechanism going forward. Windows Installer is a robust package management framework for the Microsoft Windows operating system, and works extremely well in deployment scenarios, and package management on one-off systems. It offers the capability of passing in installation parameters, a patching mechanism, dependency checking, and other functionality you’d expect from a package management service for an operating system.

TortoiseGit

msysgit claims to include GUI tools, but in my opinion, you’re better off unchecking that feature, and downloading TortoiseGit instead. It includes the overlay icons and nicer GUI screens that TortoiseHg offers, and a better Windows Explorer context menu than msysgit has. Unfortunately, TortoiseGit adds an annoying confirmation screen every time you run a Git command, like committing changes or adding/removing files. It’s an unnecessary interruption to a developer’s workflow, in my opinion. I’ll have to see if there’s an option to disable that, but otherwise, it’s pretty decent. What I really like about the “Tortoise” branded tools is the Workbench utility that allows you to view branches, commits, and details about changesets.

Atlassian SourceTree

Atlassian SourceTreeA friend, and fellow Microsoft MVP in PowerShell, Steven Murawski pointed me to another nice GUI tool for working with Git on the Windows platform. The tool is developed by Atlassian, and is called SourceTree. While SourceTree doesn’t offer any integration with Windows Explorer that I’m aware of, it is a nice GUI tool, and even works with Mercurial repositories, too! It’s nice to see tools work across multiple, similar systems; since Git and Mercurial are in the same family of revision control tools, I think this is great!

Repositories are listed in a ListView style control on the left-hand side of the SourceTree main UI window, and are also represented as tabs across the detail view area. Files that are part of the repository are listed in a separate control, with nice icons to determine the file operation in a given changeset (add, remove, changed). Check out the screenshot for a sample!

The buttons on the main menu bar are large, and easy to read. When you switch between Git and Mercurial repositories, the button labels update for the appropriate lingo in each revision control system. For example, the “Checkout” operation in Git becomes “Update” in Mercurial, the “Stash” operation becomes “Shelve,” and so on. They’re just different terms for more or less the same functionality.

Getting Start with Git

To get started with Git, on a fresh Windows system, you’ll probably want to follow these steps:

  1. Download and install msysgit
    1. Disable the Windows Explorer integration on the “Select Components” screen. This will gum up your Windows Explorer context menu with extra, unnecessary crap. We’ll use TortoiseGit instead, or SourceTree, for GUI work.
    2. Select the “Use Git from the Windows Command Prompt” option on the “Adjusting your PATH environment” screen
    3. Select the “Checkout as-is, commit as-is” option from the “Configuring the line ending conversions” screen
  2. Download and install TortoiseGit
  3. Download and install Atlassian SourceTree

Once you’ve got these tools installed, you should be ready to initialize or import your Git repositories, and start performing revision control in your development projects! If you’re a PowerShell developer, or even an administrator who’s just getting started with scripting, I highly encourage you to get familiar with basic source control operations. You will definitely thank yourself in the long run!

Conclusion

In this article, we’ve taken a look at the Windows tooling for Mercurial and Git. While the Mercurial tooling is a bit easier to use on Windows, the community around Git (and specifically the GitHub website) is stronger. I hope to see some simplification around tools like msysgit and some end user usability enhancement on the TortoiseGit side.

I hope that this information helps you to make an informed decision about which tools to use for decentralized revision control on the Windows platform. If you’re into PowerShell, and you would like to read my introductory chapter to revision control with Mercurial, then please purchase a copy of the PowerShell Deep Dives book, which I coauthored!