VSTS | TFS 2015
Whether your software project is large, small, or brand new, in most cases you'll be better off if you use version control as early as possible. Here, we'll show you how to get started with Git, a distributed version control system. If you want to work in a centralized version control system, you can instead use Team Foundation Version Control (TFVC).
Create a team project for your repositories
Team projects hold your repositories, backlogs, and builds. When you create a team project, a new repository will be automatically created for you.
If you don't already have a team project create a new team project
Install Git client tools
To use Git, you'll need to have the client tools installed on your computer.
- Install Visual Studio 2013 or Visual Studio 2015
- Or, if you're not using Visual Studio, install the latest command line tools
Clone
To get started, you'll first need to clone your repo to your local machine. Once you have a local clone, you can start adding code to your repo.
Go to your team's project page (
https://{youraccount}.visualstudio.com/DefaultCollection/{yourteamproject}) and then open Visual Studio to connect to your team project. Click Allow if prompted to open Visual Studio.
Sign in to VSTS from Visual Studio.
Clone the repository to your computer.

The clone URL is automatically populated and a default local path is provided. Change the local path to the location where you want to store your repo. Click Clone to start copying the repo locally.
Add code to your repo
Let's add a new app to the repo so we can make some changes.
Create a new project in Visual Studio from the team explorer.

Create a new Console Application. Notice that the location is set to the location on disk where the empty repo was cloned and the Add to source control option is checked.

In Team Explorer, navigate to the Changes page. Notice that your new solution is showing up on the Home page under Solutions.

The new app appears under the Included Changes section. Enter a commit message and click the Commit and Push button to commit the changes to your local repo then push your changes to Visual Studio VSTS. If you haven't previously used Git on this computer, you may have to configure your username and email address.

In your browser, view the changes pushed to the server by clicking on CODE.

Create a topic branch
In Git, branches are very lightweight and enable a lot of useful functionality. A common best practice is to perform all development in a branch (even minor changes and bug fixes). These types of branches are often called "topic branches" as they are created for a single task or topic of work.
Let's make a change in a topic branch to explore some additional features.
In Team Explorer, navigate to the Branches page.

On the Branches page, right-click on the master branch and choose New Local Branch From... to create a new topic branch.

Enter a name for your branch and click Create Branch. When naming your branches, use slashes to organize your branches.

Make a change to your app
Now that you have a new topic branch, you're ready to start making changes to your app.
Add a "hello, world" message to the console app.

Commit
Right-click on the file in Solution Explorer and choose Commit.

On the Changes page, enter a commit message and click Commit to commit the changes to your topic branch.

Publish
To share the changes in your topic branch, you'll need to publish it to the server.
Click on the Sync link in the successful commit notification to open the Synchronization page.

On the Sync page, click on the Publish link to push the changes on your topic branch to the server.

Conduct a pull request
Pull Requests are a common workflow for reviewing code created in a topic branch and merging changes. Let's create a pull request to see how it works.
In your browser, open the CODE hub and click Pull Requests to view the Pull Requests hub.

Click on New Pull Request to create a new pull request.

Select your topic branch from the first drop-down. The default branch (master) is the default target branch.

Verify that the preview contains the changes you want to review and click Create Pull Request.

Now you can add reviewers to get their feedback on your changes before you merge your changes into master.

Q&A
Q: How do I create a team project on Visual Studio VSTS?
Sign up and create your team project. Be sure to select Git from the version control options:

Q: How do I create a team project on an on-premises Team Foundation Server?
- Set up TFS on a server.
Create a team project. Be sure to select Git from the version control options:

Q: How do I get started using Command line tools?
First you'll need to:
Make sure you're set up to use the command prompt

Get the clone URL from the CODE hub in Visual Studio VSTS.
For the Fabrikam project on VSTS, the command to clone would look like this:
git clone https://fabrikam.visualstudio.com/DefaultCollection/_git/Fabrikam
Once you have the repo cloned, create a new topic branch:
git checkout -b users/jamal/new_branch
When you have changes to add to the repo, stage the files using:
git add .
Then commit to the local repo:
git commit -a -m "Initial commit"
When you're ready to publish your topic branch to the repo on VSTS, push the changes:
git push origin users/jamal/new_branch
Now you can return to the web portal to complete the pull request experience.
Q: How do I configure my Git username and email address?
Before you can commit in Visual Studio, you must configure the username and email address that Git will use to identify commits that you create.
On the Changes page, you will be prompted if you haven't configured your username or email address. You can also access the Git Settings page from the Settings page in Team Explorer, under the Git section, Global Settings.

Enter your preferred username and email address on the Git Settings page.
