Git & GitHub · Leçon 4
Les branches
À retenir
- Une branche est une ligne de développement parallèle : on y travaille sans risquer de casser
main. git switch -c nomcrée une branche et s'y place ;git switch nomchange de branche ;git branchles liste.- Pour fusionner : se placer sur la branche qui reçoit (
git switch main) puisgit merge nom. git branch -d nomsupprime une branche fusionnée.- Un conflit arrive quand la même ligne a changé des deux côtés : on choisit, on enlève les marqueurs
<<<<<<<=======>>>>>>>, puisgit addetgit commit.
Mémo
git switch -c contact
# … modifications, git add, git commit …
git switch main
git merge contact
git branch -d contact
git branch Pièges à éviter
- Fusionner depuis la mauvaise branche (
git merge maindepuis la branche de fonctionnalité). - Changer de branche avec des modifications non enregistrées : Git peut refuser.