When you work with repositories in DevOps, managing branches effectively becomes essential. In practice, if you’re not working on the main branch and you’ve created additional branches, you’ll often switch between them during development.
For example, you might have a main branch and a newly created, empty demo branch. In that case, you’ll need a simple and reliable way to move between branches while working on your cloned repository.
📝 One-Minute Brief
Switching between branches is a routine task when working with Git repositories, whether in Azure DevOps or other platforms. In this Friday Fact, I explain how you can seamlessly switch between Git branches using simple commands like git checkout. This approach helps developers work on different features or fixes without friction, making daily Git workflows faster, cleaner, and more efficient.
So, how can you do that?
First, ensure that Git is installed on your machine before you start navigating between branches. You can download and install Git here.
Next, in your DevOps, copy the repository path.


After having Git installed, you can use the cmd (command line), in the folder where you want your DevOps repository to be cloned by writing in the folder path: cmd.

This will open a command line where you can now write the git command to clone your repository.

- Clone the repository from Azure DevOps:
git clone https://<PAT>@dev.azure.com/<Organization>/<Project>/_git/<RepositoryName>
- Navigate to the newly cloned repository and on the same command line:
cd <RepositoryName>
- Initialize Git if required (this is usually done automatically):
git init
- Check out the branch where you want to add the files:
git checkout <BranchName>
- Pull the latest changes from the branch to ensure it’s up to date:
git pull origin <BranchName>
- If you have files to add to your repository, here you can add your files to the repository by copying them into the repository folder.
- Stage the changes:
git add .
- Commit the changes with a meaningful message:
git commit -m "Your commit message here"
- Push the changes to the specified branch:
git push origin <BranchName>
And so these are the steps on how you can add your files to a specific repository branch!
But how can you switch?
Once the connection between your DevOps repository and the branch is set up locally, switching between branches becomes a breeze. All you need to do is use the simple Git command:
git checkout <BranchName>
This command allows you to seamlessly switch between branches, making it easier to work on different features or tasks without any hassle. With Git set up and your branches organized, managing your workflow becomes more efficient and streamlined.
To lazy to read? We’ve got you covered! Check out our video version of this content!
Hope you find this helpful! If you enjoyed the content or found it useful and wish to support our efforts to create more, you can contribute towards purchasing a Star Wars Lego for Sandro’s son!