Home and Learn: Intermediate Programming


Version Control in Visual Studio

Stick Figure App - Version Control

 

Because this is a long project, now might be a good time to learn about version control.

You've probably done this. You're working on a file, any file, and you decide to make a few changes. Except, you don't want to ruin the original. So you click File > Save As and save the file using something like myFile_V2. You then end up with a lot of file that look like this:

myFile_V1
myFile_V2
myFile_V3
myFile_V4

What you've done here is to create your own rudimentary version control system.

There's a more sophisticated version control system built into Visual Studio called Git. (There are other versions control system, such as Subversion and Mercurial.) Git is not exactly intuitive to use. We'll cover the basics, though.

First, have a look at the bottom right of Visual Studio. You should see some white text on a blue bar saying, "Add to Source Control": (The Source is your source code.)

Add to Source Control in Visual Studio

Click on that and you'll see an item for Git:

The Git menu, Add to Source Control in Visual Studio

Click on Git and you'll see the Team Explorer tab appear on top of your Solution Explorer in the top right: (If you can't see the Team Explorer tab, or accidentally close it down, click View > Team Explorer from the menu at the top of Visual Studio.)

The Team Explorer tab in Visual Studio

What are Repositories?

The Repository mentioned in the image above is an online storage system. You would sign up to a service like Git Hub and enter the location of your repository by clicking the Publish Git Repo button under Push to Remote Repository. You can also sign up for Microsoft's Azure service and store your work there. Having a remote repository is very useful as it means your code is backed up elsewhere, rather than just on your own computer. And you can share your code with others, if you want.

However, we're just going to store (publish) our project on a local machine, meaning your own computer.

Click on the Home button at the top of the Team Explorer:

The Home button on the Team Explorer tab

The Team Explorer tab will change to this:

Options on the Home tab of the Team Explorer

The topics we'll cover are Changes and Branches. First up, is Branches. We'll explorer these in the next lesson below.

Version Control and Branches >>

<< Back to the Intermediate Contents Page


Email us: enquiry at homeandlearn.co.uk