git merge
git
Syntaxe
git merge [--no-ff|--squash] <branch>Intègre le travail d'une autre branche dans la branche courante ; --squash n'enregistre aucune fusion, git considère donc toujours cette branche comme non fusionnée.
Options courantes
| Option | Signification |
|---|---|
| --no-ff | always record a merge commit, even when a fast-forward was possible |
| --ff-only | refuse unless it can fast-forward |
| --squash | stage the combined change without committing or recording a merge |
| --abort | undo a merge that stopped on conflicts |
| --continue | finish after you resolved the conflicts |
| -X ours|theirs | auto-resolve conflicting hunks one way |
| --no-commit | merge but leave the commit to you |
Exemples
git merge --no-ff feature/loginkeeps the branch visible in history
git merge --abortgets you back to before the conflicted merge
git merge --squash feature/loginone flat change, staged; you still have to commit
Ce qui embrouille, c’est qu’annuler a plusieurs formes : déplacer là où pointe une branche n’est pas ajouter un commit qui l’inverse.
Comment lire
- Les crochets [ ] marquent une partie facultative.
- Les points de suspension … signifient qu’on peut en mettre plusieurs.
- Les options sont sensibles à la casse : sur certaines commandes, -r et -R ne font pas la même chose.
Questions fréquentes
Q. Que fait git merge ?
Intègre le travail d'une autre branche dans la branche courante ; --squash n'enregistre aucune fusion, git considère donc toujours cette branche comme non fusionnée.
Q. Comment l’écrire ?
git merge [--no-ff|--squash] <branch> — les crochets marquent ce qui est facultatif.
Q. Combien d’options valent la peine ?
Il y en a 7 ici ; la liste complète est dans man git. Cette commande relève de git.
Commandes liées
page man: man git-merge