Home Azure Cloud Getting Started with Azure Repos

Getting Started with Azure Repos

229
0

Azure Repos is a version control system in Azure DevOps that helps you store, manage, and track changes in your code. Whether you’re working alone or with a team, Azure Repos makes it easy to collaborate, review code, and maintain a history of changes.

In this guide, we’ll cover how to:

  • Create a repository and folder
  • Add and update a file
  • Perform these actions both from the Azure DevOps Portal and from your local machine

🧩 Prerequisites

Azure DevOps Project
Make sure you have an Azure DevOps Organization and Project set up. If not, follow the post Getting Started with Azure DevOps Organization.


🧱 Step 1: Create a Repository

🔹 From Azure DevOps Portal

  1. Go to you Azure DevOps project in the Azure DevOps portal as we saw in Getting Started with Azure DevOps Organization.
  2. In the left sidebar, click Repos → Files.
  3. If no repository exists, click Initialize or New repository. Else, from the dropdown next to repo name in the breadcrumbs, click on New repository.
  4. Give it a name (for example, cocan-infra-tf-dev) and click Create.

Now your repository is ready!


📁 Step 2: Create a Folder and Add a File (From Portal)

  1. In your new repo, click on the three dots “…” on the top right.
  1. Select New → Folder.
  2. Enter a folder name (for example, sample-folder) and click Create.
  3. Inside the folder, click New → File.
  4. Enter a filename (for example, readme.txt).
  5. Add some text, like This is my first file in Azure Repos.
  6. Add a commit message (for example, Initial commit) and click Commit.

Your folder and file are now stored in Azure Repos! 🎉


💻 Step 3: Clone the Repo and Work Locally

🔹 Clone Repository (Using HTTPS – Recommended)

  1. On your repo page, click Clone.
  2. Select HTTPS.
  3. Under IDE, click Open with VS Code.
  4. VS Code will launch and may prompt you to sign in with Microsoft.
  5. Sign in using the same account that has access to your Azure DevOps project.
  6. Once authenticated, VS Code clones the repository to your local machine and opens it automatically.

That’s it — you’re connected and ready to work locally without manually running Git commands! 🎯


🔑 Authentication with Microsoft Login

Azure DevOps now uses the Git Credential Manager (GCM) for secure authentication.
Instead of entering a username and password or PAT, you’ll see a Microsoft login window.
Once you sign in, a secure access token is saved automatically in your system’s credential store:

Operating SystemWhere Credentials Are Saved
WindowsWindows Credential Manager → Windows Credentials → dev.azure.com
macOSKeychain Access (search “dev.azure.com”)
LinuxStored by Git Credential Manager in the system keyring

You won’t need to re-enter your credentials until the token expires.


🔄 Forcing Re-authentication (If Needed)

Sometimes you may want to sign in again — for example, if you switched Azure DevOps accounts or the token became invalid.

To remove the saved entry and force a new login:

🪟 Windows

  1. Open Control Panel → Credential Manager → Windows Credentials.
  2. Find entries that start with dev.azure.com.
  3. Click Remove.
  4. Back in VS Code, perform any Git action (e.g., push or pull) → you’ll be prompted to sign in again.

🍎 macOS

  1. Open Keychain Access.
  2. Search for dev.azure.com and delete those entries.
  3. Retry the Git action — VS Code will show the Microsoft login prompt.

🐧 Linux

Run:

git credential-cache exit

or manually remove cached entries stored by the Git Credential Manager.


💡 Note on SSH (Use Only as a Fallback)

Azure DevOps supports SSH keys, but it’s no longer the recommended method.
SSH is primarily for situations where you cannot use the Git Credential Manager or Microsoft login, such as restricted automation environments.

HTTPS with GCM is preferred because it:

  • Integrates directly with VS Code and Azure DevOps,
  • Supports multi-factor authentication,
  • Manages tokens securely via the system credential store.

Use SSH only if HTTPS authentication is not possible in your environment.


⚙️ Step 4: Configure Git Identity (Local Config)

After cloning, configure your Git identity for this project only (local config):

git config user.name "Heartin JK"
git config user.email "heartin@heartinjacobk18.sg-host.com"

This ensures your commits are correctly attributed without affecting other projects on your system.


💡 Note: Setting Global Git Identity (Optional)

If you’d like to use the same name and email for all repositories on your computer, you can set it globally instead:

git config --global user.name "Heartin JK"
git config --global user.email "heartinjk@gmail.com"

This stores your Git identity in your global configuration file (~/.gitconfig) and applies it to every project you work on.
You can check your current settings with:

git config --list

If both global and local configurations exist, local settings take priority for that specific repository.


🧩 Step 5: Create Folder and Update File (Locally)

  1. Inside your local repo folder, create a new folder: mkdir sample-folder cd sample-folder
  2. Create or edit a file: echo "Hello from local machine!" > readme.txt
  3. Add and commit your changes: git add . git commit -m "Added readme file from local"
  4. Push your changes to Azure Repos: git push

✅ Now, when you refresh your repo in the Azure DevOps portal, you’ll see the new folder and file created locally.


🔄 Step 6: Update the File (From Either Side)

  • From Portal:
    Open the file → Click Edit → Make changes → Commit.
  • From Local:
    Edit the file in any text editor and run: git add . git commit -m "Updated readme file" git push

Both updates will reflect in Azure Repos.


🧠 Summary

TaskFrom PortalFrom Local
Create Repo
Create Folder
Add File
Update File
Push/Commit Changes

🌟 Next Steps

Now that you’ve learned how to create and manage files in Azure Repos, you can explore:

  • Branching and merging strategies
  • Pull requests and code reviews
  • Integrating pipelines for CI/CD

LEAVE A REPLY

Please enter your comment!
Please enter your name here