Getting started using Visual Studio Team Services VSTS for source control

So one of the thing I see on a regular basis is students undertaking projects but they arent using Source Control

If you have a project you’ve been working on, but haven’t yet had a chance to put it in source control DO IT NOW!

By simply spending just a few minutes you can host your project code in a  free in Visual Studio Team Services (VSTS). Or GitHub repo.

Step 1. Create your account Free MSA Account

Get started by creating your free VSTS account.  All you l need to have a Microsoft Account if you dont have a MSA simply create a new user.

Sign up for a Microsoft account

  1. Go to the Microsoft account sign-up page and tap or click Create account.
  2. In the User name box enter your existing email address, or tap or click Get a new email address to create an Outlook or Hotmail address.
  3. Fill out the rest of the form, and then tap or click Create account.

Step 2. Setting up VSTS

To Create a Visual Studio account simply head over to www.visualstudio.com and sign in

Creating your VSTS account is as easy as picking a name and  the way in which you want to manage the code and click Continue.

image

Step 3. Create a new project

Simply select new under recent projects

Enter the name of the new project and set the shared access levels

image

 

That’s it – you now have an account and a repo to store your code!

image

Your repo is empty, so let’s look at some options for getting your code into that new repo:

Step 4. Create a Git repo for your existing Visual Studio project

If you have an existing project in Visual Studio, getting that project into your new repo is easy.  Start by opening the project in Visual Studio and open the Solution Explorer.  Right click on the solution and choose Add Solution to Source Control.

image

We created a Git project initially, so choose Git from the Choose Source Control dialog.

choose-git

In the Changes page, add a comment to describe your changes and click Commit.

commit-changes

Now your changes have been committed to a new local Git repo.  To send the repo to VSTS, click the Sync link in the info bar (you can also go to the Sync page by clicking on the navigation bar in Team Explorer).

sync-changes

Click Get Started in the Publish to Visual Studio Team Services section.  Once you’ve signed in, you’ll see your new VSTS account listed, and you can either publish to a new project or the existing one that was created on sign up.  VSTS gives you unlimited free repos, so let’s create a new repo in the default project.  Click Publish to push your local Git repo up to the cloud.

image

Go back to your browser and select the new repo from the repo picker.

select-repo

Voila!  The Code Explorer now shows your project, and you’re all set to start tracking your changes.

image

Step 5. Create a Git repo for your existing code

If you have some code that’s not in Visual Studio, it’s still easy to get that code hosted in VSTS Git repo.  First, you’ll need to have Git tools installed.  Click the link to Download Git for Windows from the empty repo page.

download-git

After installing the tools, you’ll need to configure your credentials.  Click the Generate Git credentials button to generate alternate credentials that can be used from the command line.  You can also create a personal access token, or better yet, use a credential manager to handle credentials for you.

Next, open a command prompt and navigate to folder where you have the existing code project.  Type the following commands to create a new Git repo, add, and commit your changes to the repo.

 git init
git add .
git commit -a -m "My first commit"

Next, you’ll need to configure your local repo to push to the remote repo hosted in VSTS.  In the empty repo page, look under the command line instructions for the exact commands you’ll need to configure your repo to push to your account.  Click on the copy button to copy the command to your clipboard.

copy-url

Paste that command into your command prompt and press enter.  Do the same for the push command, and push enter to start the push.  After entering your account credentials, you’ll see output in the command window that shows your changes being pushed to the hosted repo.

command-push

Go back to your browser and refresh the empty repo page, and you’ll see your newly added code.

explorer-2

Step 6. Clone an empty repo and put some code into it

If you want to try out VSTS with a sample project, start by cloning down the empty repo.  To do this in VS, just click the Clone in Visual Studio button.

clone-vs

Visual Studio will open and connect to your VSTS account (you may get prompted for credentials if you haven’t signed in to VS).  In Team Explorer, you’ll see that you’re connected to the new project, and there is a prompt to clone the repository.  Click Clone this repository to start the process.

clone-vs-2

The Clone URL and a default location on disk for your repo are prepopulated.  Enter in a new folder location if you want to store the repo somewhere else.  Click Clone to start downloading the repo to your computer.

clone-confirm

Once the repo finished cloning, click the New… link in the Solutions section to create a new project in this empty repo.  Choose a project type, give it a name and click OK to create the project.

Next, you’ll want to commit your project to your repo.  Click on the Changes tile in the Team Explorer to open the Changes page.

changes-page

The Changes page will show your newly added files.  Enter a commit message and click Commit to commit the changes to your local repo.

commit-changes-2

Click on the Sync link to go to the Sync page where you can push your changes to the server.

sync-link

On the Sync page, you’ll see the change you just committed listed in the Outgoing Changes.  Click Push to send the changes to the server.

push-changes

Go back to your browser and refresh the empty repo page, and you’ll see your newly added code.

explorer-3

Step 7. Set up a CI Build

Now that you have code in your repo, get a CI build set up to start building your code.  Click on the setup now badge to get started.   Learn more about VSTS Build

setup-build

Step 8. Plan the work for your project

In addition to source code hosting and build, VSTS has all of the Agile tools you need to run your agile team.  Click on the Work hub to get started creating your backlog.  Learn more about Agile tools

plan-work

Top Reasons  why you should be using VSTS

  1. Unlimited free private repos. Really. You can create as many private Git repos as you want, and it’s completely free. We also don’t charge for storage or bandwidth, so you don’t have to worry as your codebase grows. Even better is that teams up to 5 individuals can work for free on the same account, and anyone that already has an MSDN license can also join any account for no additional charge.  More details about pricing for larger team

  2. Pull requests with integrated build and work items. Take your code reviews to the next level by configuring automated builds that can verify the pre-merged changes before the code is merged into the mainline. Projects that are using the Agile tools can link their bugs, tasks, and stories to their code to get traceability and understand the motivations behind every code change.  Learn more about pull requests

  3. Powerful history views. VSTS lets users go beyond the simple list of commits and see exactly who is pushing changes and when. The Branch Updates view shows every change that is pushed into a branch or merged with a PR, so you can know exactly who introduced every change.

  4. Awesome web editor. The rich web editor makes it easy to make a quick code change. Features like syntax highlighting for dozens of file types, Intellisense, and a rich command palette bring modern editor features into the web. Integration with pull request means that you can take the risk out of a quick edit by building and code reviewing changes before they’re merged.

  5. Enterprise level security. Beyond the enterprise level data protection provided by Azure, VSTS Git repos have the ability to control access to individual repos and even branches. Integration with Azure Active Directory makes managing access to code using your existing groups easy.

  6. First-class Visual Studio integration. We saw how easy it was to create, clone, commit, and push changes, but that was just the beginning. Branch management, rich history graph views, and conflict resolution tools make it easy to complete all of your essential Git tasks from the comfort of your IDE.