Merge branch 'sr/clone-empty'
[git] / Documentation / git-am.txt
1 git-am(1)
2 =========
3
4 NAME
5 ----
6 git-am - Apply a series of patches from a mailbox
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
13          [--3way] [--interactive]
14          [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
15          [--reject]
16          [<mbox> | <Maildir>...]
17 'git am' (--skip | --resolved | --abort)
18
19 DESCRIPTION
20 -----------
21 Splits mail messages in a mailbox into commit log message,
22 authorship information and patches, and applies them to the
23 current branch.
24
25 OPTIONS
26 -------
27 <mbox>|<Maildir>...::
28         The list of mailbox files to read patches from. If you do not
29         supply this argument, reads from the standard input. If you supply
30         directories, they'll be treated as Maildirs.
31
32 -s::
33 --signoff::
34         Add `Signed-off-by:` line to the commit message, using
35         the committer identity of yourself.
36
37 -k::
38 --keep::
39         Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
40
41 -u::
42 --utf8::
43         Pass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
44         The proposed commit log message taken from the e-mail
45         is re-coded into UTF-8 encoding (configuration variable
46         `i18n.commitencoding` can be used to specify project's
47         preferred encoding if it is not UTF-8).
48 +
49 This was optional in prior versions of git, but now it is the
50 default.   You could use `--no-utf8` to override this.
51
52 --no-utf8::
53         Pass `-n` flag to 'git-mailinfo' (see
54         linkgit:git-mailinfo[1]).
55
56 -3::
57 --3way::
58         When the patch does not apply cleanly, fall back on
59         3-way merge, if the patch records the identity of blobs
60         it is supposed to apply to, and we have those blobs
61         available locally.
62
63 --whitespace=<option>::
64 -C<n>::
65 -p<n>::
66 --directory=<dir>::
67 --reject::
68         These flags are passed to the 'git-apply' (see linkgit:git-apply[1])
69         program that applies
70         the patch.
71
72 -i::
73 --interactive::
74         Run interactively.
75
76 --skip::
77         Skip the current patch.  This is only meaningful when
78         restarting an aborted patch.
79
80 -r::
81 --resolved::
82         After a patch failure (e.g. attempting to apply
83         conflicting patch), the user has applied it by hand and
84         the index file stores the result of the application.
85         Make a commit using the authorship and commit log
86         extracted from the e-mail message and the current index
87         file, and continue.
88
89 --resolvemsg=<msg>::
90         When a patch failure occurs, <msg> will be printed
91         to the screen before exiting.  This overrides the
92         standard message informing you to use `--resolved`
93         or `--skip` to handle the failure.  This is solely
94         for internal use between 'git-rebase' and 'git-am'.
95
96 --abort::
97         Restore the original branch and abort the patching operation.
98
99 DISCUSSION
100 ----------
101
102 The commit author name is taken from the "From: " line of the
103 message, and commit author time is taken from the "Date: " line
104 of the message.  The "Subject: " line is used as the title of
105 the commit, after stripping common prefix "[PATCH <anything>]".
106 It is supposed to describe what the commit is about concisely as
107 a one line text.
108
109 The body of the message (iow, after a blank line that terminates
110 RFC2822 headers) can begin with "Subject: " and "From: " lines
111 that are different from those of the mail header, to override
112 the values of these fields.
113
114 The commit message is formed by the title taken from the
115 "Subject: ", a blank line and the body of the message up to
116 where the patch begins.  Excess whitespaces at the end of the
117 lines are automatically stripped.
118
119 The patch is expected to be inline, directly following the
120 message.  Any line that is of form:
121
122 * three-dashes and end-of-line, or
123 * a line that begins with "diff -", or
124 * a line that begins with "Index: "
125
126 is taken as the beginning of a patch, and the commit log message
127 is terminated before the first occurrence of such a line.
128
129 When initially invoking it, you give it names of the mailboxes
130 to crunch.  Upon seeing the first patch that does not apply, it
131 aborts in the middle,.  You can recover from this in one of two ways:
132
133 . skip the current patch by re-running the command with '--skip'
134   option.
135
136 . hand resolve the conflict in the working directory, and update
137   the index file to bring it in a state that the patch should
138   have produced.  Then run the command with '--resolved' option.
139
140 The command refuses to process new mailboxes while `.git/rebase-apply`
141 directory exists, so if you decide to start over from scratch,
142 run `rm -f -r .git/rebase-apply` before running the command with mailbox
143 names.
144
145 Before any patches are applied, ORIG_HEAD is set to the tip of the
146 current branch.  This is useful if you have problems with multiple
147 commits, like running 'git am' on the wrong branch or an error in the
148 commits that is more easily fixed by changing the mailbox (e.g.
149 errors in the "From:" lines).
150
151
152 SEE ALSO
153 --------
154 linkgit:git-apply[1].
155
156
157 Author
158 ------
159 Written by Junio C Hamano <gitster@pobox.com>
160
161 Documentation
162 --------------
163 Documentation by Petr Baudis, Junio C Hamano and the git-list <git@vger.kernel.org>.
164
165 GIT
166 ---
167 Part of the linkgit:git[1] suite