Using SQL Server Management Studio with Git

The Agent Git plug-in allows you to seamlessly integrate Microsoft SSMS with Git. The plug-in has been tested SSMS 2014 versions however it should also work with earlier versions of the SSMS software.

Features of the plug-in include:

  • Easy to install, easy to configure, easy to use
  • Add solutions, projects and files to Git, all from within the IDE
  • Check out, check in, get latest version all without leaving the IDE
  • Revert file changes from within the IDE
  • Provides the option of automatic file locking on check out and unlocking on check in
  • View file differences, file status and file history from within the IDE
  • The power of Git with the feel of Visual Source Safe
  • Can use an external difference tool to view file differences
SSMS

Tutorial

Described below are the steps required to get Agent Git to work with Microsoft SQL Server Management Studio 2014 and Git.

To use Agent Git with an earlier version of Microsoft SQL Server Management Studio just follow the similar steps using in that earlier version of the software.


Step 1: Agent Git Provider Setup

From within the Microsoft SQL Server Management Studio IDE use the Tools, Options menu to bring up the Options dialog and in the Source Control section select Agent Git as the active provider as shown below:

Git Repository Details


Step 2: Configure Agent Git

Bring up the Agent Git configuration as shown below:

Git Repository Details


The resulting Agent Git configuration dialog is shown below:

agent-git-setup

You can use this dialog to configure the behaviour of the plug-in.


Step 3: Create a Test SQL Project

To see how Agent Git works we need something to play with so the next step is to create a simple test project.

From within Microsoft SQL Server Management Studio IDE create a new My Scripts project as shown below:

Git Repository Details



This will result in the following project binding dialog shown below:

ssms_binding


This dialog takes two inputs, a project name and a local folder location that contains the Git repository.

In this particular case hitting the Ok button will result in the following dialog:

ssms_create_repo

The reason the dialog is displayed is because we are dealing with a new project and no Git repository exists for the project and as such the response should be Yes.

However, for the case where the project already has a Git repo the answer should be No and the path should then be modified to point to that existing Git repo.


Step 4: Create Some SQL Script to Add to the Project

Create a few SQL Query files in the project folder with the end result being a project folder that looks something like this:

Git Repository Details


Step 5: Add these Scripts to the Project

From inside the Microsoft SQL Server Management Studio IDE, add these SQL files to the project using the Solution Explorer and the end result should be a project that looks like this:

Git Repository Details

Notice that these newly added files have the plus sign on their icon, which indicates they have not yet been added to the Git repository.


Right click on the My Scripts project and use the check in option to complete the addition of these files as shown below:

Check-in files


That action will result in the check in dialog shown below:

Check-in files


After the check in is completed the icons of these files will change as shown below:

Check-in files


Use the repository browser to confirm the project files are now inside the source control repository as shown below:

Git Repository Details


Step 6: Using the Source Control

With the project fully configured and bound to the repository, you can now use the check out, check in, revert, file compare commands (or any of the other source control commands) to manage your SQL file.

Git Repository Details


You can also use the View History option to track and compare file changes as shown below:

ssms_history


Latest Version: Agent Git 1.20
Released: 28th November 2017