Using The New Git Support in WebMatrix 3

WebMatrix is probably my favorite web development IDE because it is so simple and easy to use. Sure I use Visual Studio 2012 everyday and it has probably the best web development features available on the market. I also really dig Sublime. WebMatrix is a very close second when it comes to tooling and features out of the box for me. WebMatrix is just focused on web development, which is where I live.

A new version is currently available. A few weeks ago I posted a quick guide to publishing a web site to Azure web sites. Today I want to walk you through some of the built in features that make using Git source control extremely easy.

First, up to this point I have not been much of a Git user, just when I absolutely had to use it. The main reason is I generally do not use command line tools and haven't since I was in college back in the early 90s. If you can't build a usable user interface you pretty much are not ready for general consumption in my opinion. Since there really are not good Git client applications I have been more a Mercurial or TFS guy the past few years or so.

So with that said I may be changing to Git now since WebMatrix supports the most common Git features now.

To get starting using the WebMatrix built in source control you will want to open the Source Control ribbon. If the web site's folder does not currently have any source control configured you will see two buttons, one for Git initialization and another for TFS. Obviously you would want to click the Git button to set the web site up with Git. This will take care of all the local repository setup etc.

Once the site is Git ready the Source Control ribbon will display the action buttons you need to use Git. The ribbon is broken into 3 sections; local, remote and tools.

Go Local

Once WebMatrix has configured the site for Git you can start committing code to your local repository. In the Local button group there are three buttons; Status, Commit and Branch. Status lets you see what files have changed or not been committed to the repository. The Commit button lets you select files to commit to the local repository.If you are not familiar with distributed source control, you have a local repository and make frequent commitments to your local repository. When you are ready you then push all the changes in a batch to a remote repository that others can be connected.

With that said to make commitments to the local repository you tap the Commit button. This displays a dialog that list all the uncommitted files that have changed or not been committed since the last commit. You can select and unselect files to be committed. There is also a field for you to have to provide a commit description. The description is a required field, which is a no brainer because you should always comment commits so you know what you did.

Next in the Local buttons is the Branch button. This button lets you create a branch, who would have guessed that? Branching is an important concept in source management because it lets you create new development tracks for new versions, testing ideas, bug fixes, etc. If you have been doing proper source control for any period of time you hae no doubt had up to dozens of parallel branches open at once.

Creating a branch is super easy. However I have not figured out how to merge a branch into another branch yet. I guess they could not add everything, so back to the command line or Tortoise Git for that.

What About The Remotes?

Local repositories are great, but distributed source control is all about 'cloud' based repositories. WebMatrix makes this easy as well. With Git and other distributed source control systems you push and pull source code to and from remote repositories. The Remote button group has buttons for Pull, Push and Remotes. Before you can push and pull you need to configure a remote server, so you should hit the Remote button to display the remotes configuration dialog.

You simply need to enter a remote name and a remote repository URL. You can get that URL from your source host, like GitHub or BitBucket. Don't forget TFS supports Git now!

Once at least one remote repository is setup you can push and pull code to and from the remote repository by clicking the appropriate button. No messy command line needed!

To push your commits to the remote repository just tap the Push button and off they go. If you have more than one remote location defined then you will be promoted to choose the location or you can select it by pressing the down arrow on the Push button. I wish there were more to write about but that is just how simple it is. The with psame holds true with pulling code, the only difference is your local repository is updated to the latest from the remote repository.


Finally there are two more buttons, one for settings and one to launch the dreaded Git PowerShell command line. Settings lets you configure you local file locations and merge tool. Of course the Shell button launches the Git PowerShell command line that normal Git junkies will feel right at home using. You will need to make sure you have your local machine's execution policy setup to use the PowerShell command line.

I am really excited about the built in WebMatrix Git support. This is going to make using Git a high priority for me now!

Share This Article With Your Friends!