Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
Visual Studio 2019 | Visual Studio 2022
A Git repository, or repo, tracks changes to files within a folder. You can create any number of local Git repos on your computer, each stored in its own folder. Each Git repo that you create is independent of other Git repos, so changes you make in one repo won't affect the others.
A Git repo stores every version of every file in the repo, unless you tell Git to ignore a file. Git saves file versions efficiently, so storing a large number of versions doesn't necessarily require a lot of disk space. Git supports comparing file versions, merging different versions, switching between versions, and much more. You can use Git to manage your source code, regardless of whether your code files are inside or outside of a Visual Studio solution. To share your work, you can connect your local Git repo to a remote Git repo that others can access. The remote repo can be an Azure Repos Git repo, a GitHub repo, or other hosted Git repo.
This article provides procedures for the following tasks:
For an overview of the Git workflow, see Azure Repos Git tutorial.
Category | Requirements |
---|---|
Project access | Member of a project. |
Permissions | - View code in private projects: At least Basic access. - Clone or contribute to code in private projects: Member of the Contributors security group or corresponding permissions in the project. - Set branch or repository permissions: Manage permissions permissions for the branch or repository. - Change default branch: Edit policies permissions for the repository. - Import a repository: Member of the Project Administrators security group or Git project-level Create repository permission set to Allow. For more information, see Set Git repository permissions. |
Services | Repos enabled. |
Tools | Optional. Use az repos commands: Azure DevOps CLI. |
Note
In public projects, users with Stakeholder access have full access to Azure Repos, including viewing, cloning, and contributing to code.
Category | Requirements |
---|---|
Project access | Member of a project. |
Permissions | - View code: At least Basic access. - Clone or contribute to code: Member of the Contributors security group or corresponding permissions in the project. |
Services | Repos enabled. |
Visual Studio doesn't support creating a local Git repo when you create a new solution. Instead, create your Visual Studio solution, then follow the steps in Create a local Git repo from an existing solution.
Git command line doesn't support creating a new Visual Studio solution. Instead, create your new solution using Visual Studio, then follow the steps in Create a local Git repo from an existing solution.
Create a local Git repo to track file changes in your existing Visual Studio solution.
Visual Studio 2022 provides a Git version control experience by using the Git menu, Git Changes, and through context menus in Solution Explorer. Visual Studio 2019 version 16.8 also offers the Team Explorer Git user interface. For more information, see the Visual Studio 2019 - Team Explorer tab.
In Solution Explorer, right-click the solution name, or right-click any item in the Folder view of Solution Explorer, and then select Create Git Repository. Or, choose Add to Source Control on the status bar in the lower right-hand corner of Visual Studio, and then select Git. If you don't see these options, then your code is already in a Git repo.
Or, choose Git > Create Git Repository from the menu bar to launch the Create a Git repository window. If you don't see this option, then your code is already in a Git repo.
In the Create a Git repository window, choose Local only, verify the local path is correct, and then choose Create.
You've now created a local Git repo in the Visual Studio solution folder and committed your code into that repo. Your local Git repo contains both your Visual Studio solution and Git resources.
Visual Studio 2022 doesn't support creating a new local repo by using Team Explorer. Use Git Command Line.
You can share your code with others by connecting your local Git repo to an Azure Repos Git repo.
In Solution Explorer, right-click the solution name, or right-click any item in the Folder view of Solution Explorer and then select Push to Git service to launch the Create a Git repository window.
Or, choose Git > Push to Git service from the menu bar to launch the Create a Git repository window.
Open a browser and navigate to your Azure DevOps project by using a URL in the form of https://dev.azure.com/<OrganizationName>/<ProjectName>
. If you don't have a project yet, create one.
In your Azure DevOps project, create an empty Git repo without a README file. Copy the clone URL from the Clone Repository popup.
In the Create a Git repository window, choose Existing remote and enter the repo clone URL from the previous step, and then choose Push. For more information on how to create a new Azure DevOps repo, see Create a new Git repo in your project.
Note
With Azure DevOps Services, the format for the project URL is dev.azure.com/{your organization}/{your project}
. However, the previous format that references the visualstudio.com
format is still supported. For more information, see Introducing Azure DevOps, Switch existing organizations to use the new domain name URL.
You can also share your code with others by connecting your local Git repo to a GitHub repo.
In Solution Explorer, right-click the solution name, or right-click any item in the Folder view of Solution Explorer, and then select Push to Git service to launch the Create a Git repository window.
Or, choose Git > Push to Git service from the menu bar to launch the Create a Git repository window.
In the Create a Git repository window, choose GitHub, select your GitHub account, owner name, and a new repo name, and then choose Push.
This step creates a new repo in your GitHub account with content from your local repo.
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Guided Project – Use GitHub to manage file updates - Training
Hands-on module focused on getting the learner comfortable with basic source control commands through an integrated development environment or web portal.
Documentation
Create a new Git repo in your project - Azure Repos
Create a new Git repo in an Azure DevOps project via the web portal.
Share your code with Git using Visual Studio 2015 - Azure Repos
Learn how to share your Visual Studio solution with others by hosting your code in a Git repository in Azure Repos.
Collaborate on code development using free Git public and private repositories, pull requests, and code review.