Azure Repos Tutorial
Introduction to Azure Repos
Azure Repos is a set of version control tools that you can use to manage your code. Azure Repos provides Git repositories or Team Foundation Version Control (TFVC) for source control of your code. It offers a variety of collaborative features, pull requests, advanced file management, and more.
Setting Up Azure Repos
To get started with Azure Repos, you need an Azure DevOps account and a project. Follow these steps:
- Sign in to your Azure DevOps organization (https://dev.azure.com/).
- Create a new project or navigate to an existing project.
- In the left navigation panel, click on "Repos" to access Azure Repos.
Creating a New Repository
Follow these steps to create a new repository in Azure Repos:
- Navigate to the "Repos" section of your project.
- Click on "Files" in the navigation pane.
- Click on the "New Repository" button.
- Enter a name for your repository and select either Git or TFVC as your version control system.
- Click "Create" to create the repository.
Cloning a Repository
To clone a repository, use the following steps:
- Navigate to the repository you want to clone.
- Click on the "Clone" button in the top right corner.
- Copy the URL provided.
- Open your terminal or command prompt.
- Run the following command to clone the repository:
Committing and Pushing Changes
Once you have cloned the repository, you can make changes and commit them. Follow these steps:
- Make changes to your files.
- Stage the changes using the command:
- Commit the changes with a message:
- Push the changes to the remote repository:
Creating and Managing Branches
Branches allow you to develop features and fix bugs independently from the main codebase. Here's how you can create and manage branches:
- To create a new branch, use the following command:
- To switch to an existing branch, use:
- To push a new branch to the remote repository:
- To delete a branch, use:
Pull Requests
Pull Requests (PRs) are a feature that allows you to review and merge code changes. Here's how you can create a pull request:
- Push your changes to a branch in the remote repository.
- Navigate to the "Repos" section and click on "Pull requests".
- Click "New pull request".
- Select the source and target branches for the PR.
- Provide a title and description for the PR, then click "Create".
Code Reviews
Code reviews are an essential part of the development process. Here's how you can review code in a pull request:
- Navigate to the "Pull requests" section.
- Select the pull request you want to review.
- Review the code changes, leave comments, and suggest improvements.
- Approve or request changes to the pull request.
Conclusion
Azure Repos is a powerful tool for managing your code and collaborating with your team. By following this tutorial, you should now have a good understanding of how to set up and use Azure Repos effectively. Happy coding!