Get started with Git from the command line
VSTS | TFS 2018 | TFS 2017 | TFS 2015
This guide show you how to share your code in a VSTS Git repo 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 VSTS CLI.
- A VSTS account. If you don't have one, you can sign up for one for free. Each account includes free, unlimited private Git repositories.
Download and install Git
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.
Navigate to the folder where your code is on the command line:
Create a Git repo on your machine to store your code. You will connect this repo to VSTS in the next step.
git init .
Commit your code into the local Git repo.
git add --all git commit -m "first commit of my code"
Create your VSTS repo
Create a new VSTS Git repo for your code. Copy the clone URL once you are done creating your repo.
Connect your local repo to the VSTS repo using the copied clone URL in the
git remote add origin https://fabrikops2.visualstudio.com/DefaultCollection/Fabrikam/_git/FabrikamApp
Push your code
git push origin master