Git
Next to TFVC, Azure DevOps also supports hosting Git repositories. Git is a form of decentralized source control that is rapidly gaining ground. Git is not specific to Azure DevOps but is a general protocol that is used by many platforms that provide source control hosting as a service. Well-known examples next to Azure DevOps are GitHub and GitLab.
To work with a Git repository, you must first clone it:
- Open Command Prompt and navigate to the directory where you want to store the repository.
- Execute the following command and replace the example URL with the URL to your Git repository. The example URL shows how the location of a Git repository in Azure DevOps is built up:
git clone https://{organization}@dev.azure.com/{organization}/{teamProject}/_git/{repository}
Now, you can start working on the changes you want to make. In this example, a new file, NewFile.txt, was added.
- Next, this file must be staged for commit. Staging files is done to differentiate between files you want to commit and changes you want to keep for your own:
git add NewFile.txt
- After staging all of the changes you want to group into a single commit, creating the actual commit is done by calling the commit command and specifying a description of the changes:
git commit -m "Added a new file that contains an important text"
- Finally, you can push your changes back to the central repository, the remote, by executing the following command:
git push
To make more changes, you can stage and commit changes as often as required. You can push the commits one at a time, but you can also push multiple commits at once.
You can also work with Git through the Visual Studio or VS Code interfaces. Here, you execute precisely the same steps, but instead, you can use a visual interface.