0
0
Azurecloud~5 mins

Azure Repos for source control - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you work on software projects, you need a safe place to save your code and track changes. Azure Repos is a tool that helps you store your code online and keep track of every change you make, so you never lose your work or get confused about versions.
When you want to save your project code safely in the cloud.
When you need to work with others on the same code without overwriting each other's work.
When you want to see the history of changes made to your code over time.
When you want to create backups of your code automatically.
When you want to manage different versions of your code for testing or release.
Commands
This command copies the remote Azure Repos repository to your local computer so you can start working on the code.
Terminal
git clone https://dev.azure.com/exampleorg/exampleproject/_git/example-repo
Expected OutputExpected
Cloning into 'example-repo'... remote: Azure Repos remote: Counting objects: 10, done. remote: Compressing objects: 100% (8/8), done. Receiving objects: 100% (10/10), 2.34 KiB | 1.17 MiB/s, done. Resolving deltas: 100% (3/3), done.
Change directory to the folder where the code was copied so you can work inside the project.
Terminal
cd example-repo
Expected OutputExpected
No output (command runs silently)
This command stages all your changes in the project folder, preparing them to be saved in the next commit.
Terminal
git add .
Expected OutputExpected
No output (command runs silently)
This saves your staged changes locally with a message describing what you did, like a snapshot of your work.
Terminal
git commit -m "Add initial project files"
Expected OutputExpected
[main abc1234] Add initial project files 5 files changed, 120 insertions(+)
-m - Adds a message describing the commit
This uploads your local commits to the Azure Repos server so others can see your changes and they are safely stored online.
Terminal
git push origin main
Expected OutputExpected
Enumerating objects: 7, done. Counting objects: 100% (7/7), done. Delta compression using up to 4 threads Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 1.23 KiB | 1.23 MiB/s, done. Total 5 (delta 2), reused 0 (delta 0) To https://dev.azure.com/exampleorg/exampleproject/_git/example-repo def5678..abc1234 main -> main
Key Concept

If you remember nothing else from this pattern, remember: Azure Repos safely stores your code online and tracks every change so you can work with others without losing work.

Common Mistakes
Trying to push changes without committing them first
Git only uploads saved snapshots (commits), so if you skip commit, there is nothing to push.
Always run 'git commit' after 'git add' before pushing.
Cloning the wrong repository URL
You won't get the correct project code and may get errors or empty folders.
Copy the exact clone URL from Azure Repos for your project.
Not pulling latest changes before pushing
Your push may be rejected if others changed the code since your last update.
Run 'git pull origin main' to update your local copy before pushing.
Summary
Clone your Azure Repos project to your local computer with 'git clone'.
Make changes, then stage and save them locally using 'git add' and 'git commit'.
Upload your saved changes to Azure Repos with 'git push' so they are backed up and shared.