Create a new Git repo
Azure Repos | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 Update 2
A Git repository, or repo, is a folder that you've told Git to help you track file changes in. You can have any number of repos on your computer, each stored in their own folder. Each Git repo on your system is independent, so changes saved in one Git repo don't affect the contents of another.
A Git repo contains every version of every file saved in the repo. Git saves these files very efficiently, so having a large number of versions doesn't mean that it uses a lot of disk space. Storing each version of your files helps Git merge code better and makes working with multiple versions of your code quick and easy.
In this tutorial you learn how to:
- Create a new Git repo
The following video explains what Git repos are, and shows you how to create them on your computer using Visual Studio 2015 Update 2.
Working from the command line? You can view our video overview using command line steps on Channel9.
Create a new repo
Manage any folder with source code or Visual Studio solution in Git by creating a repo for them. Later you can connect this Git repo to a remote Git repo to share your work with others.
Create a repo
- Create a repo from a new solution
- Create a repo from an existing solution
- Create a repo in an empty folder
- Connect a local repo to a remote
From a new solution
Create a new Git repo for your new Visual Studio solution by selecting Create new Git repository when creating the solution:
From an existing solution
To create a repo from an existing solution not in version control, select the Publish button in the bottom-right of the lower status bar . This creates a new Git repo in the same directory as your solution and opens up the Publish view in Team Explorer so you can push your code to Azure Repos or another remote Git repository.
In an empty folder
Open the Connect view in Team Explorer by choosing Projects then Manage Connections from the context menu.
Under Local Git Repositories, select New and enter a folder where the repo will be created. This directory must be empty.
Select Create to create the repo.
Connect a local repo to a remote
To connect a local repository to a hosted remote Git repository to share your work, go the Settings page in Team Explorer. Select Repository Settings. Under Remotes, select Add.
origin in the Name field and enter the clone URL for your repo in the Fetch field.
Make sure that Push matches fetch is checked and select Save.