</>
Plan du cours — 59/74

Cherry-pick : appliquer un commit précis d'une autre branche

Avancé
# Applique le commit abc1234 sur la branche courante, sans toucher au reste
git cherry-pick abc1234

# Cherry-pick plusieurs commits
git cherry-pick abc1234 def5678

# Cherry-pick une plage de commits (exclut abc1234, inclut def5678)
git cherry-pick abc1234..def5678

# En cas de conflit : résoudre, puis
git add .
git cherry-pick --continue

# Annuler un cherry-pick en cours
git cherry-pick --abort

Cas pratique : un correctif urgent a été commité sur main, et vous devez aussi l'appliquer sur la branche release-1.x sans tout fusionner :

git switch release-1.x
git log main --oneline -5        # repérer le hash du fix
git cherry-pick abc1234
git push origin release-1.x