Gérez des sous-projets dans un mono-repo et synchronisez-les avec subtree.
objectifs d’apprentissage
- Ajouter un subtree.
- Pull/push subtree.
- Structurer un mono-repo.
prérequis
- Repo parent.
- Repo enfant.
notions clés
- subtree add/pull/push.
- Dossiers par module.
- Isolation des historiques.
démonstration guidée
étape 1
Ajouter un subtree dans modules/lib.
git subtree add --prefix=modules/lib https://github.com/example/lib.git main --squash
étape 2
Synchroniser les changements depuis l’upstream.
git subtree pull --prefix=modules/lib https://github.com/example/lib.git main --squash
exercice
Poussez des changements locaux vers l’upstream avec subtree push.
correction
Push côté subtree.
git subtree push --prefix=modules/lib https://github.com/example/lib.git main
quiz éclair
- Quelle commande ajoute un sous-arbre ?
- a) git subtree add
- b) git submodule add
- c) git tree add