1. Branching strategies #
Trunk-based or GitFlow.
Comparison #
| Trunk-based development | GitFlow | |
|---|---|---|
| Branches | main + branches lasting a few hours | main, develop, feature, release, hotfix |
| Integration | at least daily | at the end of the feature |
| Unfinished features | hidden behind feature flags | stay in their branch |
| Suited to | continuous deployment, web services | versions maintained in parallel, shipped software |
| Risk | requires solid automated tests | merge conflicts, late integration |
Good practice: DORA research associates trunk-based development (fewer than three active branches, daily merging) with better delivery performance. Reserve GitFlow for products that maintain several versions.
2. Pull requests and reviews #
Reviewing fast and well.
A good pull request #
- Small: fewer than 400 changed lines, a single topic.
- A description that explains the why, with a link to the ticket.
- The CI pipeline is green before human review.
- Reviewed within the day: a review that waits several days is one more queue.
Protecting main #
- Merge only through pull requests, at least one approval.
- Mandatory CI statuses (tests, analysis, build).
- Linear history (squash or rebase) and branch up to date before merging.
- A
CODEOWNERSfile to automatically involve the right reviewers.
# CODEOWNERS
/infra/ @equipe-plateforme
/src/paiement/ @equipe-paiement
*.tf @equipe-plateforme3. Commits and versions #
A history readable by humans and tools.
Conventional commits #
feat(panier): ajouter le calcul des frais de port
fix(api): corriger le code HTTP en cas de stock vide
docs: documenter la variable DATABASE_URL
refactor!: renommer le champ client_id en customer_id
BREAKING CHANGE: l'API v1 n'accepte plus client_idThe prefix (feat, fix, docs, chore, refactor, test, ci) makes it possible to automatically generate the changelog and the next version number.
Semantic versioning #
| Change | Version | Example |
|---|---|---|
| Fix | PATCH | 1.4.2 → 1.4.3 |
| New compatible feature (feat) | MINOR | 1.4.3 → 1.5.0 |
| Incompatible change (BREAKING CHANGE) | MAJOR | 1.5.0 → 2.0.0 |
git tag -a v1.5.0 -m "v1.5.0"
git push origin v1.5.0
git describe --tags # version la plus proche
git log v1.4.0..v1.5.0 --oneline --no-merges # changements entre deux versionsHooks and tools #
# .git/hooks/commit-msg : refuser un message non conventionnel
#!/usr/bin/env bash
grep -qE '^(feat|fix|docs|chore|refactor|test|ci|perf|build)(\(.+\))?!?: .+' "$1" || {
echo "Message non conventionnel : type(portée): description" >&2; exit 1; }As a team, hooks are shared with pre-commit (formatting, lint, secret detection) and versions and changelog are generated with semantic-release or release-please in the pipeline.
4. Fixing without panicking #
Rescue commands.
Commands #
git revert <sha> # annuler un commit publié (crée un commit inverse)
git commit --amend # corriger le dernier commit non poussé
git rebase -i HEAD~3 # réorganiser ses commits locaux avant la PR
git reflog # retrouver un commit « perdu »
git bisect start ; git bisect bad ; git bisect good v1.4.0 # trouver le commit fautif
git stash ; git stash popGolden rule #
Common mistake: Never rewrite (rebase,push --force) the history of a shared branch such as main: usegit revert. If a force push is needed on your own branch, prefer--force-with-lease.
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
DevOps best practices: culture, CI/CD, infrastructure as code and measurement
DevOps best practices: culture and collaboration, continuous integration and delivery, trunk-base...
Git Sync in Grafana: version dashboards in GitHub
Sync Grafana dashboards and folders with a GitHub repository: prerequisites, token, setup in Admi...
The wall of confusion
The 'wall of confusion' is a metaphor often used in a DevOps context to describe the cultural, or...
Platform engineering, FinOps and AI: the new frontiers of DevOps
Understand how DevOps is evolving: platform engineering and internal developer platforms (IDP), g...
Infrastructure as Code and GitOps: Terraform, Ansible and Argo CD
Manage infrastructure as code: declarative or imperative, Terraform (providers, state, plan, modu...
Observability, SRE and incident management for DevOps teams
Operate what you ship: metrics, logs and traces, golden signals, SLIs, SLOs and error budgets, ac...
DevOps variants: understanding how engineering culture has evolved
Discover the different flavors of DevOps: DevSecOps, AIOps, NoOps, GitOps and FinOps. Understand ...
End-to-end CI/CD (1/5): principles and anatomy of a pipeline
Understand end-to-end CI/CD: continuous integration, continuous delivery and continuous deploymen...
End-to-end CI/CD (2/5): continuous integration, testing and quality
Succeed with continuous integration: the test pyramid, unit, integration, contract and end-to-end...