Chapter 18. Using Source Control Software with PowerShell

 

Trevor Sullivan

Windows PowerShell is a phenomenal tool for automation, but with great power comes great responsibility. Over time you’ll find that your script repository will grow larger and larger, and you’ll frequently need to modify scripts to provide additional functionality, fix bugs, or make your code more readable. As your repository grows and morphs it’s important to maintain a history of changes to your script files. The benefits of keeping track of history are many, most importantly including the ability to revert to an old version of a script if you make a breaking modification.

In this chapter I’ll describe the benefits of using source control and how to perform basic source control functions. It’s my hope that you’ll begin to appreciate the benefits that using source control software can provide to you, and will seek a deeper understanding of its capabilities.

Requirements

For this chapter of PowerShell Deep Dive you’ll need several pieces of software:

  • Microsoft Windows 7/8 system running Windows Management Framework 3.0
  • Microsoft .NET Framework 4.0 (required for PowerShell v3)
  • TortoiseHg, available from http://tortoisehg.bitbucket.org
  • Mercurial (included with TortoiseHg)

When to use source control

Introduction to Mercurial

Common source control operations

Using Mercurial from PowerShell

Working with Mercurial in teams

Summary

About the Author