Accueil·Commandes du terminal

git format-patch

git

Syntaxe

git format-patch [-<n>|<since>] [-o <dir>]

Écrit un fichier .patch au format courriel par commit ; format-patch main désigne les commits postérieurs à main, pas main lui-même.

Options courantes

OptionSignification
-<n>the last n commits, e.g. -3
<since>commits after that one, e.g. origin/main
-o <dir>write the files into a directory
--stdoutone mbox stream on standard output
--cover-letteradd a 0000 summary mail
-v <n>mark the series as v<n> of a re-roll
-sadd Signed-off-by

Exemples

git format-patch -3

writes 0001- to 0003- patch files for the last three commits

git format-patch origin/main --cover-letter -o outbox/

a mailable series of everything not yet upstream

git format-patch -1 --stdout > fix.patch

one commit as a single patch file

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 format-patch ?

Écrit un fichier .patch au format courriel par commit ; format-patch main désigne les commits postérieurs à main, pas main lui-même.

Q. Comment l’écrire ?

git format-patch [-<n>|<since>] [-o <dir>] — 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-format-patch