Skip to main content

Git

Git is a version control system. It keeps track of changes in your files over time.

Why use Git (especially for IaC like Bicep)

  • History / rollback: see who changed what, and revert if something breaks.
  • Safe collaboration: multiple people can work on the same repository without overwriting each other.
  • Change control: review changes before they go to main (via Pull Requests in most teams).
  • Traceability: link commits to a ticket/change request for auditing.
  • Repeatable deployments: a specific commit = a known-good version of the infrastructure code.

Key words (quick glossary)

  • Repository: the folder tracked by Git (contains a hidden .git folder).
  • Commit: a saved snapshot of your changes + a message.
  • Branch: a separate line of work (used to make changes safely).
  • Main/master: the primary branch (often protected).
  • Remote: the server copy (e.g., GitHub/Azure DevOps). origin is the common name.
  1. Create a branch for your change
  2. Make edits
  3. Commit with a clear message
  4. Push your branch to the remote
  5. Open a Pull Request (PR) to merge into main

How to create a branch and commit (Terminal)

Run these commands from your repository folder in the Visual Studio Code terminal.

  • Check status (optional but useful)

    git status
  • Create and switch to a new branch Use a descriptive name (often includes a ticket number).

    git checkout -b docs/bicep-bicepparam-and-git

    Alternative (newer Git command):

    git switch -c docs/bicep-bicepparam-and-git
  • Stage your changes (select what will be included in the commit) Stage everything:

    git add .

    Or stage only one file:

    git add .\docs\bicep\bicep.md
  • Commit with a message

    git commit -m "Docs: explain bicep deploy files, bicepparam, and basic git workflow"
  • Push the branch to the remote (first push)

    git push -u origin docs/bicep-bicepparam-and-git

After this, you typically create a Pull Request in your Git platform UI and request review.

How to do the same in Visual Studio Code (no terminal)

  • Open the Source Control view (left sidebar).
  • Branch
    • Click the branch name in the bottom-left status bar.
    • Choose Create new branch...
    • Enter a branch name.
  • Make your edits.
  • In Source Control:
    • Click + next to files to stage them (or Stage All).
    • Type a commit message in the message box.
    • Click Commit.
  • Click Sync Changes (or Push) to send your branch to the remote.

Good commit message tips (easy rule)

  • Start with what you changed: Docs:, Fix:, Feat:, Chore:
  • Keep it short but specific

Create a Pull Request (PR) in Azure DevOps

Prerequisites

  • Your changes are committed locally

  • Your branch is pushed to Azure DevOps (remote), for example:

    git push -u origin your-branch-name

Steps on the Azure DevOps site

  • Open your project

    • Go to your Azure DevOps Organization
    • Select the correct Project
  • Go to Repos

    • In the left menu, click Repos

    • Then click Files (or Branches)

    • Start the Pull Request You can do this in a few common ways:

      Option A (from the "Create a pull request" banner)

    • After pushing a branch, Azure DevOps often shows a banner like "Create a pull request"

    • Click it

      Option B (from Branches list)

    • Go to Repos → Branches

    • Find your branch (e.g. docs/bicep-bicepparam-and-git)

    • Click the ⋯ (More options) next to the branch

    • Select Create pull request

      Option C (from Pull Requests page)

    • Go to Repos → Pull requests

    • Click New pull request

  • Set source and target

    • Source branch: your feature branch (the one with your changes)
    • Target branch: usually main (or whatever your team uses)
  • Fill in PR details

    • Title: short and clear (example: Docs: add Git overview page)
    • Description: what changed, why, and any notes for reviewers
    • Optional: link a Work Item (ticket) if your team uses them
  • Add reviewers

    • Add the required people/teams under Reviewers
    • Some repositories auto-add reviewers via branch policies
  • Check policies (if enabled)

    • Azure DevOps may require:
      • Minimum number of approvals
      • Successful build/validation
      • Linked work item
      • No merge conflicts
    • Fix any warnings shown on the PR page
  • Create the PR

    • Click Create
  • After approval: complete the PR

    • When it’s approved and checks pass, click Complete
    • Common options:
      • Delete source branch (recommended)
      • Squash commits (if your team prefers)
      • Autocomplete (finishes automatically when policies pass)

If you see "merge conflicts"

  • Update your branch with latest main, then push again:

    git fetch origin
    git switch your-branch-name
    git merge origin/main
    git push