Git
English
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
.gitfolder). - 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).
originis the common name.
Basic workflow (recommended)
- Create a branch for your change
- Make edits
- Commit with a clear message
- Push your branch to the remote
- 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-gitAlternative (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
- Title: short and clear (example:
-
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
- Azure DevOps may require:
-
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 origingit switch your-branch-namegit merge origin/maingit push
Nederlands
Git is een versiebeheersysteem. Het houdt wijzigingen in je bestanden bij.
Waarom Git gebruiken (vooral voor IaC zoals Bicep)?
- Geschiedenis en terugdraaien: zie wie wat heeft gewijzigd en draai wijzigingen terug als er iets misgaat.
- Veilig samenwerken: meerdere mensen kunnen aan dezelfde repository werken zonder elkaars wijzigingen te overschrijven.
- Wijzigingsbeheer: beoordeel wijzigingen voordat ze naar
maingaan (in veel teams via pull requests). - Traceerbaarheid: koppel commits aan een ticket of wijzigingsaanvraag voor controle achteraf.
- Herhaalbare implementaties: een specifieke commit is een bekende versie van de infrastructuurcode.
Belangrijke termen (korte woordenlijst)
- Repository: de map die Git bijhoudt (bevat een verborgen map
.git). - Commit: een opgeslagen momentopname van je wijzigingen met een bericht.
- Branch: een aparte werklijn waarmee je veilig wijzigingen kunt maken.
- Main/master: de primaire branch, die vaak is beveiligd.
- Remote: de serverkopie, bijvoorbeeld op GitHub of Azure DevOps.
originis een veelgebruikte naam.
Basisworkflow (aanbevolen)
- Maak een branch voor je wijziging.
- Breng wijzigingen aan.
- Maak een commit met een duidelijke omschrijving.
- Push je branch naar de remote repository.
- Open een pull request (PR) om de wijzigingen samen te voegen met
main.
Een branch maken en committen (terminal)
Voer deze opdrachten uit in de repositorymap, in de terminal van Visual Studio Code.
-
Status controleren (optioneel, maar handig)
git status -
Een nieuwe branch maken en ernaartoe schakelen Gebruik een beschrijvende naam, eventueel met een ticketnummer.
git checkout -b docs/bicep-bicepparam-and-gitAlternatief (nieuwere Git-opdracht):
git switch -c docs/bicep-bicepparam-and-git -
Wijzigingen klaarzetten voor de commit (selecteer wat erin komt) Alle wijzigingen klaarzetten:
git add .Of slechts één bestand klaarzetten:
git add .\docs\bicep\bicep.md -
Een commit maken met een bericht
git commit -m "Docs: explain bicep deploy files, bicepparam, and basic git workflow" -
De branch voor de eerste keer naar de remote pushen
git push -u origin docs/bicep-bicepparam-and-git
Maak hierna meestal een pull request in de interface van je Git-platform en vraag om een beoordeling.
Dezelfde workflow in Visual Studio Code (zonder terminal)
- Open de weergave Source Control in de linkerzijbalk.
- Branch
- Klik op de branchnaam in de statusbalk linksonder.
- Kies Create new branch...
- Voer een branchnaam in.
- Breng je wijzigingen aan.
- In Source Control:
- Klik naast bestanden op + om ze klaar te zetten voor de commit (of kies Stage All).
- Typ een commitbericht in het berichtveld.
- Klik op Commit.
- Klik op Sync Changes of Push om je branch naar de remote te sturen.
Tips voor commitberichten (eenvoudige regel)
- Begin met wat je hebt gewijzigd:
Docs:,Fix:,Feat:ofChore:. - Houd het bericht kort en specifiek.
Een pull request (PR) maken in Azure DevOps
Vereisten
-
Je wijzigingen zijn lokaal gecommit.
-
Je branch is naar Azure DevOps (remote) gepusht, bijvoorbeeld:
git push -u origin your-branch-name
Stappen op de Azure DevOps-site
-
Open je project
- Ga naar je Azure DevOps-organisatie.
- Selecteer het juiste Project.
-
Ga naar Repos
-
Klik in het linkermenu op Repos.
-
Klik vervolgens op Files of Branches.
-
Start de pull request. Dat kan op een paar gebruikelijke manieren:
Optie A (via de banner "Create a pull request")
-
Na het pushen van een branch toont Azure DevOps vaak de banner Create a pull request.
-
Klik erop.
Optie B (via de lijst met branches)
-
Ga naar Repos → Branches.
-
Zoek je branch, bijvoorbeeld
docs/bicep-bicepparam-and-git. -
Klik naast de branch op ⋯ (More options).
-
Selecteer Create pull request.
Optie C (via de pagina Pull Requests)
-
Ga naar Repos → Pull requests.
-
Klik op New pull request.
-
-
Stel de bron- en doelbranch in
- Source branch: je featurebranch, de branch met je wijzigingen.
- Target branch: meestal
main, of de branch die je team gebruikt.
-
Vul de PR-gegevens in
- Title: kort en duidelijk, bijvoorbeeld
Docs: add Git overview page. - Description: beschrijf wat er is gewijzigd, waarom en eventuele aandachtspunten voor reviewers.
- Koppel eventueel een Work Item als je team dat gebruikt.
- Title: kort en duidelijk, bijvoorbeeld
-
Voeg reviewers toe
- Voeg de vereiste personen of teams toe onder Reviewers.
- Sommige repositories voegen reviewers automatisch toe via branchbeleid.
-
Controleer het beleid (indien ingeschakeld)
- Azure DevOps kan het volgende vereisen:
- Een minimumaantal goedkeuringen.
- Een geslaagde build of validatie.
- Een gekoppeld work item.
- Geen mergeconflicten.
- Los eventuele waarschuwingen op die op de PR-pagina worden getoond.
- Azure DevOps kan het volgende vereisen:
-
Maak de PR
- Klik op Create.
-
Voltooi de PR na goedkeuring
- Klik op Complete wanneer de PR is goedgekeurd en de controles zijn geslaagd.
- Veelgebruikte opties:
- Delete source branch (aanbevolen).
- Commits Squashen als je team dat verkiest.
- Autocomplete inschakelen om de PR automatisch af te ronden zodra het beleid is nageleefd.
Als je "merge conflicts" ziet
-
Werk je branch bij met de nieuwste versie van
mainen push daarna opnieuw:git fetch origingit switch your-branch-namegit merge origin/maingit push