Accueil·Commandes du terminal

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

OptionSignification
--no-ffalways record a merge commit, even when a fast-forward was possible
--ff-onlyrefuse unless it can fast-forward
--squashstage the combined change without committing or recording a merge
--abortundo a merge that stopped on conflicts
--continuefinish after you resolved the conflicts
-X ours|theirsauto-resolve conflicting hunks one way
--no-commitmerge but leave the commit to you

Exemples

git merge --no-ff feature/login

keeps the branch visible in history

git merge --abort

gets you back to before the conflicted merge

git merge --squash feature/login

one 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