Deep Dive into Advanced Git Features
In this tutorial you’ll learn how to leverage powerful Git capabilities within Azure Repos to keep your codebase clean, secure, and highly maintainable.
1. Git Submodules
Submodules let you embed a repository inside another. This is handy for shared libraries or components that evolve independently.
# Add a submodule
git submodule add https://dev.azure.com/contoso/SharedLib/_git/shared-lib external/shared-lib
git commit -m "Add shared-lib submodule"
2. Advanced Branching Strategies
Implement Git Flow or Trunk‑Based Development using Azure Pipelines policies to enforce PR reviews and required builds.
- Feature branches → Pull Request → Review → Build validation
- Release branches → Tagging & Continuous delivery
- Hotfix branches → Immediate merge to
mainandrelease
3. Rebase vs Merge
Choose the right integration method for your workflow.
# Rebase a feature branch onto main
git fetch origin
git rebase origin/main
# Merge with a fast‑forward safe flag
git merge --ff-only feature‑xyz
4. Branch Protection & Policies
Configure branch policies in Azure Repos to require:
- Minimum number of reviewers (e.g., 2)
- Successful build validation
- Work item linking
- Automatic comment resolution