Azure version control is a powerful tool that helps you manage changes to your codebase. It's a must-have for any developer working on a team, as it allows multiple users to collaborate on the same project without conflicts.
Azure provides a robust version control system that supports Git, which is the most widely used version control system in the world. This means you can use all the familiar Git commands and features you're used to.
By using Azure version control, you can track changes to your code, collaborate with team members, and even roll back to previous versions if needed. It's a game-changer for any development project.
One of the key benefits of Azure version control is that it's highly scalable, making it perfect for large teams and complex projects.
Getting Started
To begin with Azure version control, you need to start by opening the DevOps Portal for Azure at https://dev.azure.com and logging in with your company credentials.
The DevOps Portal is the main interface for Azure, where you'll find all the tools and features you need to manage your code and collaborate with your team.
First, you need to log in with your company credentials to access the Azure DevOps interface.
From there, you can start exploring the different features and tools available, such as Azure Repos, which allows you to store and manage your code.
To access Azure Repos, you'll need to navigate through the portal and find the relevant section.
Repository Management
Repository Management is a breeze in Azure DevOps. You can manage your repo branches from the Azure DevOps portal, in addition to all the functionality available in Visual Studio Code.
To create a new repository, simply click on the "New repository" option from the project Add dropdown. This will allow you to set the Repository name and even create a file named README.md, which will be the default markdown file rendered when someone navigates to the repo root in a browser.
You can also preconfigure the repo with a .gitignore file to specify which files to ignore from source control. There are multiple templates available that include common patterns and paths to ignore based on the project type you are creating.
To create a new project in Azure DevOps, sign in to your Azure DevOps account and click Start free. If you need a project for a new organization, click New organization and specify its name, country/region, and preferred hosting location.
A new project with the repository is displayed on the Projects page, where you can commit, push changes, add files, and make changes. If your project is private, make sure to provide required users with access to your repository.
Here's a quick rundown of the steps to create a new project:
- Specify a name for your project and set the visibility depending on whether you want your project to be private or public
- Optionally, enter a project description
- Select Git from the Version control drop-down list
- Select a Work item process according to your needs (Basic, Agile, CMMI, or Scrum)
- Once it's all done, click Create
Version Control Basics
You need to select a version control system when creating a new project in Azure DevOps.
This is done by selecting Git from the Version control drop-down list.
A Work item process is also selected according to your needs, with options including Basic, Agile, CMMI, and Scrum.
To create a new project, you need to specify a name and set the visibility, which can be either private or public.
New Project
Creating a new project in Azure DevOps is the first step to managing your code and collaborating with others. You can start by signing in to your Azure DevOps account and clicking Start free.
To create a new project, you'll need to specify a name and set the visibility depending on whether you want your project to be private or public. This is crucial for controlling access to your repository.
You can optionally enter a project description to provide context for your project. This can be useful for future reference or for sharing with team members.
To set up version control, select Git from the Version control drop-down list. This will allow you to manage changes to your code and collaborate with others.
You'll also need to select a Work item process according to your needs. The available options include Basic, Agile, CMMI, and Scrum.
Here are the steps to create a new project in Azure DevOps:
- Specify a name for your project and set the visibility depending on whether you want your project to be private or public
- Optionally, enter a project description
- Select Git from the Version control drop-down list
- Select a Work item process according to your needs
- Once it's all done, click Create
After creating your project, you'll be able to commit, push changes, add files, and make changes to your repository.
Cloning a Repository
Cloning a repository is a crucial step in working with version control. It allows you to get a local copy of a Git repo from Azure Repos.
You can navigate to your team project on Azure DevOps in a browser tab. From there, you can access the Repos hub and click Clone. This will give you a repo clone URL that you can use to get a copy of the codebase.
To clone the repository, you'll need to open an instance of Visual Studio Code. Then, press Ctrl+Shift+P to show the Command Palette. Execute the Git: Clone command and paste in the URL to your repo.
You'll be prompted to select a local path to clone the repo to. Once you've selected a path, you'll be asked to log in to your Azure DevOps account. After the cloning has completed, you can click Open to open the cloned repository.
Here's a step-by-step guide to cloning a repository:
- Navigate to your team project on Azure DevOps
- Access the Repos hub and click Clone
- Paste the repo clone URL into Visual Studio Code's Command Palette
- Execute the Git: Clone command
- Select a local path to clone the repo to
- Log in to your Azure DevOps account
- Click Open to open the cloned repository
Committing Changes
To commit changes, you need to save your work and tell Git that you want to record the changes. From the Source Control tab, click the Stage Changes button for the file you want to commit. This will prepare the file for committing.
You can also add a comment to the file before committing it. For example, if you're editing the CartItem.cs class, you can add a comment to the file and save it. Then, from the Source Control tab, click the Stage Changes button for the file.
To commit staged changes, enter a comment and select Commit Staged from the More Actions dropdown. This will commit the staged changes without committing any other changes.
Here's a step-by-step guide to committing changes:
- Open the file you want to commit.
- Add a comment to the file and save it.
- From the Source Control tab, click the Stage Changes button for the file.
- Enter a comment and select Commit Staged from the More Actions dropdown.
- Click the Synchronize Changes button to synchronize the committed changes with the server.
Remember to always save your work before committing changes, and make sure to commit staged changes separately from other changes.
Authenticate with DVC
Authentication is a crucial step in using DVC, and there are several ways to do it. You can use default authentication or custom authentication.
DVC tries to authenticate with its default credential by default, which uses environment variables or data from certain Microsoft applications. This might not work for everyone, so you may need to enable some exclusion parameters depending on your setup.
You can use a connection string to authenticate with DVC configuration parameters. A connection string is recommended and includes the account name. If you give a connection string, the account name is ignored.
To use Active Directory (AD) service principal auth, you need to give tenant_id, client_id, and client_secret. You can set these config params with dvc remote modify --local, using environment variables or an Azure CLI config file.
You can also use a storage account key or a shared access signature token to authenticate. If you set allow_anonymous_login to true, anonymous read access will be tried as a last resort, but an account name is still needed. This only works with public containers.
Here are the authentication methods with dvc remote modify --local:
- A connection string is used if given (recommended) (account_name is ignored since it's included in the connection string).
- If tenant_id, client_id, and client_secret are given, Active Directory (AD) service principal auth is used.
- A storage account key (account_key) or a shared access signature token (sas_token), in this order.
- If allow_anonymous_login is set, then anonymous read access will be tried as a last resort. An account_name is still needed. Only works with public containers.
Branching and Merging
Branching and Merging is a fundamental concept in Azure Version Control, and it's essential to understand how to work with branches to manage your code effectively.
You can manage your work in the Azure DevOps Git repo from the Branches view on the web, and customize it to track the branches you care most about. This allows you to stay on top of changes made by your team.
Committing changes to a branch will not affect other branches, and you can share branches with others without having to merge the changes into the main project. This makes it easy to isolate changes for a feature or a bug fix from your master branch and other work.
Git uses the history information stored in commits to recreate the files on a branch when you start working on it, which makes switching between branches quick and easy.
Here are some key benefits of using branches in Azure Version Control:
To create a new branch, you can use the Azure DevOps portal or Visual Studio Code. In the Azure DevOps portal, you can navigate to Repos | Branches and click New branch to create a new branch. In Visual Studio Code, you can use the Command Palette to create a new branch.
When you're finished with a branch, you can delete it from the Azure DevOps portal or Visual Studio Code. Be careful when deleting branches, as this will permanently remove the branch and all of its changes.
Frequently Asked Questions
Is Azure DevOps Git or TFVC?
Azure DevOps uses standard Git, not Team Foundation Version Control (TFVC). Learn more about using Git in Azure DevOps.
What is Azure versioning?
Azure versioning is a feature that captures the state of a blob at a specific point in time, creating a new version with a unique ID each time the blob is modified. This allows for tracking changes to a blob over time.
What is the difference between version control and source control?
Version control and source control are often used interchangeably, but technically, version control refers to the process of tracking changes, while source control refers to the system managing those changes, including code development history and conflict resolution.
Sources
- https://www.azuredevopslabs.com/labs/azuredevops/git/
- https://docs.weblate.org/en/latest/vcs.html
- https://www.devart.com/dbforge/sql/source-control/version-controlling-git-in-azure-devops.html
- https://www.geeksforgeeks.org/version-control-with-azure-repos/
- https://dvc.org/doc/user-guide/data-management/remote-storage/azure-blob-storage
Featured Images: pexels.com