logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-am.1 (13492B)


  1. '\" t
  2. .\" Title: git-am
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-AM" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-am \- Apply a series of patches from a mailbox
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fIgit am\fR [\-\-signoff] [\-\-keep] [\-\-[no\-]keep\-cr] [\-\-[no\-]utf8] [\-\-no\-verify]
  36. [\-\-[no\-]3way] [\-\-interactive] [\-\-committer\-date\-is\-author\-date]
  37. [\-\-ignore\-date] [\-\-ignore\-space\-change | \-\-ignore\-whitespace]
  38. [\-\-whitespace=<action>] [\-C<n>] [\-p<n>] [\-\-directory=<dir>]
  39. [\-\-exclude=<path>] [\-\-include=<path>] [\-\-reject] [\-q | \-\-quiet]
  40. [\-\-[no\-]scissors] [\-S[<keyid>]] [\-\-patch\-format=<format>]
  41. [\-\-quoted\-cr=<action>]
  42. [\-\-empty=(stop|drop|keep)]
  43. [(<mbox> | <Maildir>)\&...\:]
  44. \fIgit am\fR (\-\-continue | \-\-skip | \-\-abort | \-\-quit | \-\-retry | \-\-show\-current\-patch[=(diff|raw)] | \-\-allow\-empty)
  45. .fi
  46. .SH "DESCRIPTION"
  47. .sp
  48. Splits mail messages in a mailbox into commit log messages, authorship information, and patches, and applies them to the current branch\&. You could think of it as a reverse operation of \fBgit-format-patch\fR(1) run on a branch with a straight history without merges\&.
  49. .SH "OPTIONS"
  50. .PP
  51. (<mbox>|<Maildir>)\&...\:
  52. .RS 4
  53. The list of mailbox files to read patches from\&. If you do not supply this argument, the command reads from the standard input\&. If you supply directories, they will be treated as Maildirs\&.
  54. .RE
  55. .PP
  56. \-s, \-\-signoff
  57. .RS 4
  58. Add a
  59. \fBSigned\-off\-by\fR
  60. trailer to the commit message, using the committer identity of yourself\&. See the signoff option in
  61. \fBgit-commit\fR(1)
  62. for more information\&.
  63. .RE
  64. .PP
  65. \-k, \-\-keep
  66. .RS 4
  67. Pass
  68. \fB\-k\fR
  69. flag to
  70. \fIgit mailinfo\fR
  71. (see
  72. \fBgit-mailinfo\fR(1))\&.
  73. .RE
  74. .PP
  75. \-\-keep\-non\-patch
  76. .RS 4
  77. Pass
  78. \fB\-b\fR
  79. flag to
  80. \fIgit mailinfo\fR
  81. (see
  82. \fBgit-mailinfo\fR(1))\&.
  83. .RE
  84. .PP
  85. \-\-[no\-]keep\-cr
  86. .RS 4
  87. With
  88. \fB\-\-keep\-cr\fR, call
  89. \fIgit mailsplit\fR
  90. (see
  91. \fBgit-mailsplit\fR(1)) with the same option, to prevent it from stripping CR at the end of lines\&.
  92. \fBam\&.keepcr\fR
  93. configuration variable can be used to specify the default behaviour\&.
  94. \fB\-\-no\-keep\-cr\fR
  95. is useful to override
  96. \fBam\&.keepcr\fR\&.
  97. .RE
  98. .PP
  99. \-c, \-\-scissors
  100. .RS 4
  101. Remove everything in body before a scissors line (see
  102. \fBgit-mailinfo\fR(1))\&. Can be activated by default using the
  103. \fBmailinfo\&.scissors\fR
  104. configuration variable\&.
  105. .RE
  106. .PP
  107. \-\-no\-scissors
  108. .RS 4
  109. Ignore scissors lines (see
  110. \fBgit-mailinfo\fR(1))\&.
  111. .RE
  112. .PP
  113. \-\-quoted\-cr=<action>
  114. .RS 4
  115. This flag will be passed down to
  116. \fIgit mailinfo\fR
  117. (see
  118. \fBgit-mailinfo\fR(1))\&.
  119. .RE
  120. .PP
  121. \-\-empty=(drop|keep|stop)
  122. .RS 4
  123. How to handle an e\-mail message lacking a patch:
  124. .PP
  125. \fBdrop\fR
  126. .RS 4
  127. The e\-mail message will be skipped\&.
  128. .RE
  129. .PP
  130. \fBkeep\fR
  131. .RS 4
  132. An empty commit will be created, with the contents of the e\-mail message as its log\&.
  133. .RE
  134. .PP
  135. \fBstop\fR
  136. .RS 4
  137. The command will fail, stopping in the middle of the current
  138. \fBam\fR
  139. session\&. This is the default behavior\&.
  140. .RE
  141. .RE
  142. .PP
  143. \-m, \-\-message\-id
  144. .RS 4
  145. Pass the
  146. \fB\-m\fR
  147. flag to
  148. \fIgit mailinfo\fR
  149. (see
  150. \fBgit-mailinfo\fR(1)), so that the Message\-ID header is added to the commit message\&. The
  151. \fBam\&.messageid\fR
  152. configuration variable can be used to specify the default behaviour\&.
  153. .RE
  154. .PP
  155. \-\-no\-message\-id
  156. .RS 4
  157. Do not add the Message\-ID header to the commit message\&.
  158. \fBno\-message\-id\fR
  159. is useful to override
  160. \fBam\&.messageid\fR\&.
  161. .RE
  162. .PP
  163. \-q, \-\-quiet
  164. .RS 4
  165. Be quiet\&. Only print error messages\&.
  166. .RE
  167. .PP
  168. \-u, \-\-utf8
  169. .RS 4
  170. Pass
  171. \fB\-u\fR
  172. flag to
  173. \fIgit mailinfo\fR
  174. (see
  175. \fBgit-mailinfo\fR(1))\&. The proposed commit log message taken from the e\-mail is re\-coded into UTF\-8 encoding (configuration variable
  176. \fBi18n\&.commitEncoding\fR
  177. can be used to specify the project\(cqs preferred encoding if it is not UTF\-8)\&.
  178. .sp
  179. This was optional in prior versions of git, but now it is the default\&. You can use
  180. \fB\-\-no\-utf8\fR
  181. to override this\&.
  182. .RE
  183. .PP
  184. \-\-no\-utf8
  185. .RS 4
  186. Pass
  187. \fB\-n\fR
  188. flag to
  189. \fIgit mailinfo\fR
  190. (see
  191. \fBgit-mailinfo\fR(1))\&.
  192. .RE
  193. .PP
  194. \-3, \-\-3way, \-\-no\-3way
  195. .RS 4
  196. When the patch does not apply cleanly, fall back on 3\-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally\&.
  197. \fB\-\-no\-3way\fR
  198. can be used to override am\&.threeWay configuration variable\&. For more information, see am\&.threeWay in
  199. \fBgit-config\fR(1)\&.
  200. .RE
  201. .PP
  202. \-\-rerere\-autoupdate, \-\-no\-rerere\-autoupdate
  203. .RS 4
  204. After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution\&.
  205. \fB\-\-no\-rerere\-autoupdate\fR
  206. is a good way to double\-check what
  207. \fBrerere\fR
  208. did and catch potential mismerges, before committing the result to the index with a separate
  209. \fBgit\fR
  210. \fBadd\fR\&.
  211. .RE
  212. .PP
  213. \-\-ignore\-space\-change, \-\-ignore\-whitespace, \-\-whitespace=<action>, \-C<n>, \-p<n>, \-\-directory=<dir>, \-\-exclude=<path>, \-\-include=<path>, \-\-reject
  214. .RS 4
  215. These flags are passed to the
  216. \fIgit apply\fR
  217. (see
  218. \fBgit-apply\fR(1)) program that applies the patch\&.
  219. .sp
  220. Valid <action> for the
  221. \fB\-\-whitespace\fR
  222. option are:
  223. \fBnowarn\fR,
  224. \fBwarn\fR,
  225. \fBfix\fR,
  226. \fBerror\fR, and
  227. \fBerror\-all\fR\&.
  228. .RE
  229. .PP
  230. \-\-patch\-format
  231. .RS 4
  232. By default the command will try to detect the patch format automatically\&. This option allows the user to bypass the automatic detection and specify the patch format that the patch(es) should be interpreted as\&. Valid formats are mbox, mboxrd, stgit, stgit\-series, and hg\&.
  233. .RE
  234. .PP
  235. \-i, \-\-interactive
  236. .RS 4
  237. Run interactively\&.
  238. .RE
  239. .PP
  240. \-n, \-\-no\-verify
  241. .RS 4
  242. By default, the pre\-applypatch and applypatch\-msg hooks are run\&. When any of
  243. \fB\-\-no\-verify\fR
  244. or
  245. \fB\-n\fR
  246. is given, these are bypassed\&. See also
  247. \fBgithooks\fR(5)\&.
  248. .RE
  249. .PP
  250. \-\-committer\-date\-is\-author\-date
  251. .RS 4
  252. By default the command records the date from the e\-mail message as the commit author date, and uses the time of commit creation as the committer date\&. This allows the user to lie about the committer date by using the same value as the author date\&.
  253. .RE
  254. .PP
  255. \-\-ignore\-date
  256. .RS 4
  257. By default the command records the date from the e\-mail message as the commit author date, and uses the time of commit creation as the committer date\&. This allows the user to lie about the author date by using the same value as the committer date\&.
  258. .RE
  259. .PP
  260. \-\-skip
  261. .RS 4
  262. Skip the current patch\&. This is only meaningful when restarting an aborted patch\&.
  263. .RE
  264. .PP
  265. \-S[<keyid>], \-\-gpg\-sign[=<keyid>], \-\-no\-gpg\-sign
  266. .RS 4
  267. GPG\-sign commits\&. The
  268. \fBkeyid\fR
  269. argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space\&.
  270. \fB\-\-no\-gpg\-sign\fR
  271. is useful to countermand both
  272. \fBcommit\&.gpgSign\fR
  273. configuration variable, and earlier
  274. \fB\-\-gpg\-sign\fR\&.
  275. .RE
  276. .PP
  277. \-\-continue, \-r, \-\-resolved
  278. .RS 4
  279. After a patch failure (e\&.g\&. attempting to apply conflicting patch), the user has applied it by hand and the index file stores the result of the application\&. Make a commit using the authorship and commit log extracted from the e\-mail message and the current index file, and continue\&.
  280. .RE
  281. .PP
  282. \-\-resolvemsg=<msg>
  283. .RS 4
  284. When a patch failure occurs, <msg> will be printed to the screen before exiting\&. This overrides the standard message informing you to use
  285. \fB\-\-continue\fR
  286. or
  287. \fB\-\-skip\fR
  288. to handle the failure\&. This is solely for internal use between
  289. \fIgit rebase\fR
  290. and
  291. \fIgit am\fR\&.
  292. .RE
  293. .PP
  294. \-\-abort
  295. .RS 4
  296. Restore the original branch and abort the patching operation\&. Revert the contents of files involved in the am operation to their pre\-am state\&.
  297. .RE
  298. .PP
  299. \-\-quit
  300. .RS 4
  301. Abort the patching operation but keep HEAD and the index untouched\&.
  302. .RE
  303. .PP
  304. \-\-retry
  305. .RS 4
  306. Try to apply the last conflicting patch again\&. This is generally only useful for passing extra options to the retry attempt (e\&.g\&.,
  307. \fB\-\-3way\fR), since otherwise you\(cqll just see the same failure again\&.
  308. .RE
  309. .PP
  310. \-\-show\-current\-patch[=(diff|raw)]
  311. .RS 4
  312. Show the message at which
  313. \fBgit\fR
  314. \fBam\fR
  315. has stopped due to conflicts\&. If
  316. \fBraw\fR
  317. is specified, show the raw contents of the e\-mail message; if
  318. \fBdiff\fR, show the diff portion only\&. Defaults to
  319. \fBraw\fR\&.
  320. .RE
  321. .PP
  322. \-\-allow\-empty
  323. .RS 4
  324. After a patch failure on an input e\-mail message lacking a patch, create an empty commit with the contents of the e\-mail message as its log message\&.
  325. .RE
  326. .SH "DISCUSSION"
  327. .sp
  328. The commit author name is taken from the "From: " line of the message, and commit author date is taken from the "Date: " line of the message\&. The "Subject: " line is used as the title of the commit, after stripping common prefix "[PATCH <anything>]"\&. The "Subject: " line is supposed to concisely describe what the commit is about in one line of text\&.
  329. .sp
  330. "From: ", "Date: ", and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers\&.
  331. .sp
  332. The commit message is formed by the title taken from the "Subject: ", a blank line and the body of the message up to where the patch begins\&. Excess whitespace at the end of each line is automatically stripped\&.
  333. .sp
  334. The patch is expected to be inline, directly following the message\&. Any line that is of the form:
  335. .sp
  336. .RS 4
  337. .ie n \{\
  338. \h'-04'\(bu\h'+03'\c
  339. .\}
  340. .el \{\
  341. .sp -1
  342. .IP \(bu 2.3
  343. .\}
  344. three\-dashes and end\-of\-line, or
  345. .RE
  346. .sp
  347. .RS 4
  348. .ie n \{\
  349. \h'-04'\(bu\h'+03'\c
  350. .\}
  351. .el \{\
  352. .sp -1
  353. .IP \(bu 2.3
  354. .\}
  355. a line that begins with "diff \-", or
  356. .RE
  357. .sp
  358. .RS 4
  359. .ie n \{\
  360. \h'-04'\(bu\h'+03'\c
  361. .\}
  362. .el \{\
  363. .sp -1
  364. .IP \(bu 2.3
  365. .\}
  366. a line that begins with "Index: "
  367. .RE
  368. .sp
  369. is taken as the beginning of a patch, and the commit log message is terminated before the first occurrence of such a line\&.
  370. .sp
  371. When initially invoking \fBgit\fR \fBam\fR, you give it the names of the mailboxes to process\&. Upon seeing the first patch that does not apply, it aborts in the middle\&. You can recover from this in one of two ways:
  372. .sp
  373. .RS 4
  374. .ie n \{\
  375. \h'-04' 1.\h'+01'\c
  376. .\}
  377. .el \{\
  378. .sp -1
  379. .IP " 1." 4.2
  380. .\}
  381. skip the current patch by re\-running the command with the
  382. \fB\-\-skip\fR
  383. option\&.
  384. .RE
  385. .sp
  386. .RS 4
  387. .ie n \{\
  388. \h'-04' 2.\h'+01'\c
  389. .\}
  390. .el \{\
  391. .sp -1
  392. .IP " 2." 4.2
  393. .\}
  394. hand resolve the conflict in the working directory, and update the index file to bring it into a state that the patch should have produced\&. Then run the command with the
  395. \fB\-\-continue\fR
  396. option\&.
  397. .RE
  398. .sp
  399. The command refuses to process new mailboxes until the current operation is finished, so if you decide to start over from scratch, run \fBgit\fR \fBam\fR \fB\-\-abort\fR before running the command with mailbox names\&.
  400. .sp
  401. Before any patches are applied, ORIG_HEAD is set to the tip of the current branch\&. This is useful if you have problems with multiple commits, like running \fIgit am\fR on the wrong branch or an error in the commits that is more easily fixed by changing the mailbox (e\&.g\&. errors in the "From:" lines)\&.
  402. .SH "HOOKS"
  403. .sp
  404. This command can run \fBapplypatch\-msg\fR, \fBpre\-applypatch\fR, and \fBpost\-applypatch\fR hooks\&. See \fBgithooks\fR(5) for more information\&.
  405. .SH "CONFIGURATION"
  406. .sp
  407. Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
  408. .PP
  409. am\&.keepcr
  410. .RS 4
  411. If true, git\-am will call git\-mailsplit for patches in mbox format with parameter
  412. \fB\-\-keep\-cr\fR\&. In this case git\-mailsplit will not remove \er from lines ending with \er\en\&. Can be overridden by giving
  413. \fB\-\-no\-keep\-cr\fR
  414. from the command line\&. See
  415. \fBgit-am\fR(1),
  416. \fBgit-mailsplit\fR(1)\&.
  417. .RE
  418. .PP
  419. am\&.threeWay
  420. .RS 4
  421. By default,
  422. \fBgit\fR
  423. \fBam\fR
  424. will fail if the patch does not apply cleanly\&. When set to true, this setting tells
  425. \fBgit\fR
  426. \fBam\fR
  427. to fall back on 3\-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally (equivalent to giving the
  428. \fB\-\-3way\fR
  429. option from the command line)\&. Defaults to
  430. \fBfalse\fR\&. See
  431. \fBgit-am\fR(1)\&.
  432. .RE
  433. .SH "SEE ALSO"
  434. .sp
  435. \fBgit-apply\fR(1), \fBgit-format-patch\fR(1)\&.
  436. .SH "GIT"
  437. .sp
  438. Part of the \fBgit\fR(1) suite