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
DevSecOps: securing the software supply chain end to end
Integrate security into the DevOps pipeline: shift-left, threat modeling, secret detection, SAST,...
The CALMS framework: the 5 pillars of DevOps
Discover the CALMS framework, the essential foundation for a successful DevOps transformation, th...
Measuring DevOps performance: DORA metrics, SPACE and continuous improvement
Measure and improve delivery performance: the DORA metrics (deployment frequency, lead time, chan...
End-to-end CI/CD (3/5): artifacts, registries and environments
Deliver continuously: immutable, versioned artifacts, image and package registries, promoting the...
End-to-end CI/CD (4/5): deployment strategies and rollback
Deploy without downtime and without risk: recreate, rolling update, blue/green, canary, feature f...
End-to-end CI/CD (5/5): GitHub Actions, GitLab CI, Jenkins and Argo CD in practice
Compare and use CI/CD tools: GitHub Actions, GitLab CI, Jenkins, Argo CD and Flux; a complete pip...
Organizing DevOps: value streams, teams and a blameless culture
Set up a DevOps organization: value chain and value stream mapping, Team Topologies, « you build ...
Containers, Kubernetes and cloud native in a DevOps approach
The role of containers and Kubernetes in DevOps: reproducible images, multi-stage Dockerfiles, re...
Terraform modules: designing, versioning and reusing
Structure Terraform with modules: root module and child modules, inputs and outputs, sources (loc...