Skip to content

Free Personal Source Control with Visual Studio and Git

Free Personal Source Control with Visual Studio and GitDo you work on projects in Visual Studio? Are you looking for a free and simple way to source control your projects without sharing them with the whole world? Would you like to be able to manage your projects online and still be able to work on your projects offline? If so, you may want to look into using Visual Studio and Git.

As a speaker and blogger, I create projects for demos, videos and screenshots. When I only had a few projects it worked quite well to “source control” my projects: I kept them in a OneDrive folder, created copies of demo code for new presentations and maintained versions manually.

However, the projects grew in number and size and became more difficult to maintain. There were no easy ways to track how I changed and improved my code over time, and I couldn’t revert to previous code. I kept telling everyone else to use source control, so I decided it was finally time to source control my personal projects.

In this post I will show you how I added my first project to source control with Visual Studio and Git.

Source Control Options

I mainly work with SSIS (SQL Server Integration Services) and Biml (Business Intelligence Markup Language) projects in Visual Studio 2013. I wanted a source control solution that supported SQL Server and Business Intelligence projects, that didn’t require me to install a lot of software on my laptop and that I could access and manage online.

GitHubGitHub
The first option I looked at was the widely used and well-known GitHub. However, the free plan was only for public repositories. The cheapest plan with private repositories was $7 per month. I’m pretty sure that no one but me would be interested in my personal projects, but I didn’t like the idea of making my cluttered work-in-progress code public.

GitLabGitLab.com
After searching for GitHub alternatives, I looked at GitLab.com. It sounded good at first: “GitLab.com hosts your (private) software projects for free.” Unlimited private repositories, completely free. There was just one little thing: They clearly state on their front page: “Disadvantages: Right now GitLab.com is really slow.”

BitBucketBitBucket
Then I looked at BitBucket, a popular option that is free for small teams up to five users. I use Atlassian’s other products (JIRA, Confluence and HipChat) at work. They are very powerful tools, but they sometimes feel a bit clunky. The desktop client SourceTree had that same clunky feeling to me.

Visual Studio Team ServicesVisual Studio Team Services
After looking at GitHub, GitLab.com and BitBucket, I realized that deep down I was really just looking for something similar to Team Foundation Server that I use at work. I already knew how to use it, it is integrated in Visual Studio, and the lazy developer in me didn’t really want to learn a whole new interface.

I found out that Team Foundation Server Express is free for five users, but even better: they have a hosted service called Visual Studio Team Services. “Five users free, unlimited private repos, developer tools, training and support”? Dear Microsoft, I knew you had moved towards a more open-source community, but I was slow. I didn’t realize just how much you offer to developers who want to work with your products. Thank you!

I finally decided that Visual Studio Team Services was the right source control option for me.

Setting up Accounts and Software

Visual Studio Dev Essentials Account
If you don’t already have a Visual Studio subscription, join the Visual Studio Dev Essentials program. You will get many benefits, including:

And much, much more. I have only listed what is relevant for me as a Data Warehouse and Business Intelligence developer. If you are an app developer, you have many other benefits waiting for you :)

Team Explorer for Visual Studio
If you don’t already have it installed, download Team Explorer for Visual Studio. I had to download and install Team Explorer for Visual Studio 2013:
Download Team Explorer

Visual Studio Team Services Account
Go to Visual Studio Team Services and create your free account.
Create Free VIsual Studio Team Services Account

When you are logged into your Visual Studio account, you can go to your profile and create an account from there. This is also how you create additional accounts.
Create Additional Free Visual Studio Team Services Account

Create your site URL. If you live outside the US, you may want to click Change details and host your projects in another location. (At the time I am writing this you can choose between South Central US, West Europe and Australia East.)
Create Site URL

Creating your First Team Project

After you have created your Visual Studio Team Services account, it is time to create your first team project. Make sure you select Git as the Version control:
Create Your First Team Project

When the project is created, you will see a Congratulations! popup:
First Team Project - Congratulations!

If you close the popup, you will see your overview dashboard:
Team Project Overview Dashboard

If you click on Add Code in the popup, you will be taken to a new page. From this new page you can click Clone in Visual Studio to launch Visual Studio. You can also go to your overview dashboard and click Open in Visual Studio to launch Visual Studio:
Add Code - Clone in Visual Studio Team Project Overview - Open in Visual Studio

Working on your Project in Visual Studio

Tip: I was not familiar with Git concepts. If you are new to Git as well, you may want to read the Git documentation or check out the Using Git with Visual Studio 2013 Jump Start on Microsoft Virtual Academy before continuing in Visual Studio :)

Cloning your repository
In Visual Studio you will see the Team Explorer prompting you to clone your repository to a local folder. Click Clone this repository, choose a local folder, and click Clone:
Team Explorer - Clone Repository Team Explorer - Clone Repository to Local Folder Team Explorer - Repository Cloned Successfully

Adding new projects to your repository
You can now add new projects to your repository, or open existing projects from your repository.
Team Explorer - New or Open Project

Adding existing projects to your repository
You can also add existing projects to your repository by copying (or moving) the project folder to your repository folder.
Copy Existing Project to Repository Existing Project Copied to Repository Existing Project in Team Explorer

Configure user settings
If this is the first time you use Git on your computer, you will have to configure your user name and e-mail address. Click Changes, click Configure, verify your user settings, and click Update:
Team Explorer Changes Team Explorer Changes - Configure User Team Explorer Changes - Configure User Settings

Included Changes, Excluded Changes and Untracked Files
If you have used Git on your computer before, you will not have to configure your user name and e-mail address again. You will see the included changes, excluded changes and untracked files in the Team Explorer. What you see depends on your project. In my case, the generated .user and .suo files were untracked, while my other project files were included:
Team Explorer Changes - Overview

If your files are untracked, you need to add them to the included files before they can be committed. To add your entire project, click Add All. You can also right-click on the project and click Add, or even click and drag the project to Included Changes. The files are now included and ready to be committed. You will see the change type next to the file name, in my case the change is [add]:
Team Explorer Changes - Add All Team Explorer Changes - Add Team Explorer Changes - Tracked Project

Commit changes
When you are ready to commit your changes, enter a commit message (a descriptive one!) and choose the commit type:
Team Explorer Changes - Commit Team Explorer Changes - Successful Commit

There are three types of commits:

  • Commit – Commit changes to local repository
  • Commit and Push – Commit changes to local repository, then push changes to remote repository
  • Commit and Sync – Commit changes to local repository, pull changes (if any) from remote repository, then push all changes to remote repository

Since I work alone on my projects, I don’t have to worry about pulling changes from other team members. This simplifies my commit process. The main thing that made me choose Git over other source control systems is that I can commit locally when I’m offline, and then push and sync when I’m online. It is extremely fast, and I can work just as well on an airplane as in my office :)

View and Compare History

There are many ways you can view and compare history, both in Visual Studio and in Visual Studio Team Services.

View and compare history in Visual Studio
In the Team Explorer, you can click Actions and then View History. In the Solution Explorer, you can right-click on the project or a single file and then View History:
Team Explorer - View History Solution Explorer - View History

View history
If you View History for one file, you will see the commits, the commit message, the commit number, who committed and when the commit was made. (You will also see the branches, in this case master, but I will not cover branching and merging in this post.) You can right-click to Compare with Previous:
History for One File History for One File - Compare with Previous

Compare history
When you compare with a previous version, you will see what has changed. In this example, the code marked with red has been removed, and the code marked with green has been added. On the right side you will see a navigation pane that shows where in the code something has changed:
History for One File - Diff

View and compare history in Visual Studio Team Services
You can also view and compare your history in Visual Studio Team Services:
Visual Studio Team Services - View History Visual Studio Team Services - Compare History

Summary

In this post I added my first project to source control with Visual Studio and Git. I showed how to set up a Visual Studio Team Services account, how to create a Team Project, how to work with Git in Visual Studio, and how to view and compare history in Visual Studio and in Visual Studio Team Services.

I did not cover Git commands or branching / merging in this post. I also did not cover all the features in Visual Studio Team Services. There are simply too many things to cover in one blog post! I recommend that you just start using Visual Studio and Git, and experiment and dig into all the great features. Some of my main resources are listed below :)

Resources

About the Author

Cathrine Wilhelmsen is a Microsoft Data Platform MVP, BimlHero Certified Expert, international speaker, author, blogger, and chronic volunteer. She loves data and coding, as well as teaching and sharing knowledge - oh, and sci-fi, chocolate, coffee, and cats :)

Comments

Hi! This is Cathrine. Thank you so much for visiting my blog. I'd love to hear your thoughts, but please keep in mind that I'm not technical support for any products mentioned in this post :) Off-topic questions, comments and discussions may be moderated. Be kind to each other. Thanks!

Hey Catherine, are you using the latest SSDT or a full version of visual studio? It looks like they’ve removed the facility to install Team Explorer directly for vs 2015 and I can’t seem to get the cool new git extension working either > https://visualstudio.github.com/ because it looks like it’d help

Great blog though! :)

Hi Alex, I’m currently using Visual Studio Professional 2013 for SQL Server 2014 Business Intelligence projects. I also have Visual Studio 2015 Shell (SSDT) installed, and Team Explorer was included in the default installation. However, I use Visual Studio Team Services, not GitHub. I haven’t installed the GitHub extension and have no experience with that :)

Thank you for the lightning response Cathrine! The problem was the Visual C++ Redistributables for Visual Studio 2015 that the VS 2015 Enterprise iso tries to install are basically broken. (but Team Explorer did come bundled with it) sorry to trouble you. Keep up the good work!

No problem, I’m happy to hear you figured it out! Thank you for the feedback :)

Nice comparison, and glad you like VSTS. I use it along with Github and they both work well. I haven’t tried Bitbucket, but a few people have recommended that.

One note, when you create the project, might mention that you checked GIT and not TFS for the version control. I believe this defaults to TFS and some people might miss this.

That’s a good point, I’ve updated the text and picture to make it clearer that you have to select Git. Thank you, Steve! :)

Great article Catherine. Personally, for small closed source client source projects I go with bitbucket. Usually if I’m the only developer I don’t use the ticket systems. If a project is big enough to require tickets because I’m working on more than one thing at a time, I’ll host on Github. I mainly use the command line though.

One thing to remember is its easy to clone a repository between different remotes, so if you ever want to migrate from one site to another, or keep multipe mirrors, that’s super simple.

Thanks, Justin! Very nice tip about cloning and migrating repositories :)

Thank you Catherine,
one question: can VSTS be used also for SSIS projects? In your post you write about BIML projects.

Thank you,
Roberto

Yes, Biml is used for SSIS development, so it absolutely works for SSIS projects as well.

Hi! This is Cathrine (again). Just a reminder. I'd love to hear your thoughts, but please keep in mind that I'm not technical support for any products mentioned in this post :) Off-topic questions, comments and discussions may be moderated. Be kind to each other. Thanks!

Share Your Thoughts?