Get started with Git from the command line

Azure Repos | TFS 2018 | TFS 2017 | TFS 2015

This guide shows you how to share your code in a Git repo in Azure Repos using the command line.

The instructions below use the default bash shell used on Linux and macOS, but the Git commands will work in any shell, including Git Bash from Git for Windows.


You can also create and get repos from the command line or scripts using the Azure DevOps Services CLI.


  • An organization in Azure DevOps. If you don't have an organization, you can sign up for one for free. Each organization includes free, unlimited private Git repositories.

Download and install Git


Download and install Git for Windows , which includes the Git Credential Manager to easily connect to Azure Repos.


Use Homebrew to install and set up Git.

brew install git

Linux and Unix

Use your distribution's package management system to download and install Git. For example, on Ubuntu:

sudo apt-get install git

Refer to the list of install commands for the most up to date instructions for your Linux distribution.

Create your local repo

Create a local Git repo for your code. If your code is already in a local Git repo, you can skip this step.

  1. Navigate to the folder where your code is on the command line:

    cd /home/fabrikam/fiber
  2. Create a Git repo on your machine to store your code. You will connect this repo to Azure Repos in the next section.

    git init .
  3. Commit your code into the local Git repo.

    git add --all
    git commit -m "first commit of my code"

Create your Git repo in Azure Repos

  1. Create a new Git repo in Azure Repos for your code. Copy the clone URL once you are done creating your repo.

    Get the clone URL after creating the Git repo in Azure Repos

  2. Connect your local repo to the Git repo in Azure Repos using the copied clone URL in the git remote command:

    git remote add origin

Push your code

Before pushing your code, set up authentication with credential managers or SSH before continuing.

git push origin master

Next steps