Quickstart: Code with Git

Azure DevOps Services | TFS 2018 | TFS 2017 | TFS 2015 | TFS 2013

In this quickstart, you learn how to share your code with others. After you create a new organization and project in Azure DevOps, you can begin coding with Git.

To work with a Git repo, you clone it to your computer. Cloning a repo creates a complete local copy of the repo for you to work with, and downloads all commits and branches in the repo and sets up a named relationship with the repo on the server. Use this relationship to interact with the existing repo, pushing and pulling changes to share code with your team.

Install Git command line tools

  1. Install one of the following Git command line tools:

Clone the repo to your computer


The New navigation feature provides a vertical navigation experience and is in preview for Azure DevOps Services. When you enable new navigation, you automatically enable several new Agile tool features that are described in the New Work Hubs blog post.

On-premises Microsoft Team Foundation Server users can select Previous navigation for guidance.

  1. From your web browser, open the project for your Azure DevOps organization and select Repos. If you don't have a project, create one now.

    Project, select Repos to clone URL

  2. Select Clone in the upper-right corner of the Code window and copy the URL.

    Open project and select Code to clone URL

  1. Open the Git command window (Git Bash on Git for Windows), navigate to the folder where you want the code from the repo stored on your computer, and run git clone followed by the path copied from the Clone URL in the previous step, as shown in the following example.

    git clone >https://contoso-ltd.visualstudio.com/MyFirstProject/_git/contoso->demo

    A copy of the code is downloaded in Git, including all commits and branches from the repo, into a new folder for you to work with.

    Keep this command window open, as you'll use it in the following steps.

Work with the code

In the following steps, we'll make a change to the files on your computer, commit the changes locally, push the commit to the repo that is stored on the server, and view the changes there.

  1. Browse to the folder on your computer where you cloned the repo, open the README.md file in your editor of choice, make some changes, and save and close the file.

  2. In the Git command window, navigate to the contoso-demo directory by entering the following command:

    cd contoso-demo
  3. Commit your changes by entering the following command in the Git command window:

    git commit -a -m "My first commit"

    When you're using git commit, -a means to commit all changed files, and -m specifies a commit message.

  4. Push your changes up to the Git repo on the server by entering the following command into the Git command window:

    git push

View history

  1. Switch back to the web portal and select History from the Code page to view your new commit.

    Select Code, then History to view commits

  2. Switch to the Files tab and select the README file to view your changes.

    Files tab, view changes in README file

Next steps

Or, learn more about working with a Git repo