builtin-commit: add --date option
[git/vmiklos.git] / Documentation / git-commit.txt
blobcbbbeeb151b8a06cec3c9497cc29e9710a21d92b
1 git-commit(1)
2 =============
4 NAME
5 ----
6 git-commit - Record changes to the repository
8 SYNOPSIS
9 --------
10 [verse]
11 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
12            [(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]
13            [--allow-empty] [--no-verify] [-e] [--author=<author>]
14            [--date=<date>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...]
16 DESCRIPTION
17 -----------
18 Stores the current contents of the index in a new commit along
19 with a log message from the user describing the changes.
21 The content to be added can be specified in several ways:
23 1. by using 'git-add' to incrementally "add" changes to the
24    index before using the 'commit' command (Note: even modified
25    files must be "added");
27 2. by using 'git-rm' to remove files from the working tree
28    and the index, again before using the 'commit' command;
30 3. by listing files as arguments to the 'commit' command, in which
31    case the commit will ignore changes staged in the index, and instead
32    record the current content of the listed files (which must already
33    be known to git);
35 4. by using the -a switch with the 'commit' command to automatically
36    "add" changes from all known files (i.e. all files that are already
37    listed in the index) and to automatically "rm" files in the index
38    that have been removed from the working tree, and then perform the
39    actual commit;
41 5. by using the --interactive switch with the 'commit' command to decide one
42    by one which files should be part of the commit, before finalizing the
43    operation.  Currently, this is done by invoking 'git-add --interactive'.
45 The `--dry-run` option can be used to obtain a
46 summary of what is included by any of the above for the next
47 commit by giving the same set of parameters (options and paths).
49 If you make a commit and then find a mistake immediately after
50 that, you can recover from it with 'git-reset'.
53 OPTIONS
54 -------
55 -a::
56 --all::
57         Tell the command to automatically stage files that have
58         been modified and deleted, but new files you have not
59         told git about are not affected.
61 -C <commit>::
62 --reuse-message=<commit>::
63         Take an existing commit object, and reuse the log message
64         and the authorship information (including the timestamp)
65         when creating the commit.
67 -c <commit>::
68 --reedit-message=<commit>::
69         Like '-C', but with '-c' the editor is invoked, so that
70         the user can further edit the commit message.
72 --reset-author::
73         When used with -C/-c/--amend options, declare that the
74         authorship of the resulting commit now belongs of the committer.
75         This also renews the author timestamp.
77 -F <file>::
78 --file=<file>::
79         Take the commit message from the given file.  Use '-' to
80         read the message from the standard input.
82 --author=<author>::
83         Override the author name used in the commit.  You can use the
84         standard `A U Thor <author@example.com>` format.  Otherwise,
85         an existing commit that matches the given string and its author
86         name is used.
88 --date=<date>::
89         Override the date used in the commit.
91 -m <msg>::
92 --message=<msg>::
93         Use the given <msg> as the commit message.
95 -t <file>::
96 --template=<file>::
97         Use the contents of the given file as the initial version
98         of the commit message. The editor is invoked and you can
99         make subsequent changes. If a message is specified using
100         the `-m` or `-F` options, this option has no effect. This
101         overrides the `commit.template` configuration variable.
103 -s::
104 --signoff::
105         Add Signed-off-by line by the committer at the end of the commit
106         log message.
108 -n::
109 --no-verify::
110         This option bypasses the pre-commit and commit-msg hooks.
111         See also linkgit:githooks[5].
113 --allow-empty::
114         Usually recording a commit that has the exact same tree as its
115         sole parent commit is a mistake, and the command prevents you
116         from making such a commit.  This option bypasses the safety, and
117         is primarily for use by foreign scm interface scripts.
119 --cleanup=<mode>::
120         This option sets how the commit message is cleaned up.
121         The  '<mode>' can be one of 'verbatim', 'whitespace', 'strip',
122         and 'default'. The 'default' mode will strip leading and
123         trailing empty lines and #commentary from the commit message
124         only if the message is to be edited. Otherwise only whitespace
125         removed. The 'verbatim' mode does not change message at all,
126         'whitespace' removes just leading/trailing whitespace lines
127         and 'strip' removes both whitespace and commentary.
129 -e::
130 --edit::
131         The message taken from file with `-F`, command line with
132         `-m`, and from file with `-C` are usually used as the
133         commit log message unmodified.  This option lets you
134         further edit the message taken from these sources.
136 --amend::
137         Used to amend the tip of the current branch. Prepare the tree
138         object you would want to replace the latest commit as usual
139         (this includes the usual -i/-o and explicit paths), and the
140         commit log editor is seeded with the commit message from the
141         tip of the current branch. The commit you create replaces the
142         current tip -- if it was a merge, it will have the parents of
143         the current tip as parents -- so the current top commit is
144         discarded.
147 It is a rough equivalent for:
148 ------
149         $ git reset --soft HEAD^
150         $ ... do something else to come up with the right tree ...
151         $ git commit -c ORIG_HEAD
153 ------
154 but can be used to amend a merge commit.
157 You should understand the implications of rewriting history if you
158 amend a commit that has already been published.  (See the "RECOVERING
159 FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)
161 -i::
162 --include::
163         Before making a commit out of staged contents so far,
164         stage the contents of paths given on the command line
165         as well.  This is usually not what you want unless you
166         are concluding a conflicted merge.
168 -o::
169 --only::
170         Make a commit only from the paths specified on the
171         command line, disregarding any contents that have been
172         staged so far. This is the default mode of operation of
173         'git-commit' if any paths are given on the command line,
174         in which case this option can be omitted.
175         If this option is specified together with '--amend', then
176         no paths need to be specified, which can be used to amend
177         the last commit without committing changes that have
178         already been staged.
180 -u[<mode>]::
181 --untracked-files[=<mode>]::
182         Show untracked files (Default: 'all').
184 The mode parameter is optional, and is used to specify
185 the handling of untracked files. The possible options are:
188         - 'no'     - Show no untracked files
189         - 'normal' - Shows untracked files and directories
190         - 'all'    - Also shows individual files in untracked directories.
193 See linkgit:git-config[1] for configuration variable
194 used to change the default for when the option is not
195 specified.
197 -v::
198 --verbose::
199         Show unified diff between the HEAD commit and what
200         would be committed at the bottom of the commit message
201         template.  Note that this diff output doesn't have its
202         lines prefixed with '#'.
204 -q::
205 --quiet::
206         Suppress commit summary message.
208 --dry-run::
209         Do not create a commit, but show a list of paths that are
210         to be committed, paths with local changes that will be left
211         uncommitted and paths that are untracked.
213 \--::
214         Do not interpret any more arguments as options.
216 <file>...::
217         When files are given on the command line, the command
218         commits the contents of the named files, without
219         recording the changes already staged.  The contents of
220         these files are also staged for the next commit on top
221         of what have been staged before.
224 EXAMPLES
225 --------
226 When recording your own work, the contents of modified files in
227 your working tree are temporarily stored to a staging area
228 called the "index" with 'git-add'.  A file can be
229 reverted back, only in the index but not in the working tree,
230 to that of the last commit with `git reset HEAD -- <file>`,
231 which effectively reverts 'git-add' and prevents the changes to
232 this file from participating in the next commit.  After building
233 the state to be committed incrementally with these commands,
234 `git commit` (without any pathname parameter) is used to record what
235 has been staged so far.  This is the most basic form of the
236 command.  An example:
238 ------------
239 $ edit hello.c
240 $ git rm goodbye.c
241 $ git add hello.c
242 $ git commit
243 ------------
245 Instead of staging files after each individual change, you can
246 tell `git commit` to notice the changes to the files whose
247 contents are tracked in
248 your working tree and do corresponding `git add` and `git rm`
249 for you.  That is, this example does the same as the earlier
250 example if there is no other change in your working tree:
252 ------------
253 $ edit hello.c
254 $ rm goodbye.c
255 $ git commit -a
256 ------------
258 The command `git commit -a` first looks at your working tree,
259 notices that you have modified hello.c and removed goodbye.c,
260 and performs necessary `git add` and `git rm` for you.
262 After staging changes to many files, you can alter the order the
263 changes are recorded in, by giving pathnames to `git commit`.
264 When pathnames are given, the command makes a commit that
265 only records the changes made to the named paths:
267 ------------
268 $ edit hello.c hello.h
269 $ git add hello.c hello.h
270 $ edit Makefile
271 $ git commit Makefile
272 ------------
274 This makes a commit that records the modification to `Makefile`.
275 The changes staged for `hello.c` and `hello.h` are not included
276 in the resulting commit.  However, their changes are not lost --
277 they are still staged and merely held back.  After the above
278 sequence, if you do:
280 ------------
281 $ git commit
282 ------------
284 this second commit would record the changes to `hello.c` and
285 `hello.h` as expected.
287 After a merge (initiated by 'git-merge' or 'git-pull') stops
288 because of conflicts, cleanly merged
289 paths are already staged to be committed for you, and paths that
290 conflicted are left in unmerged state.  You would have to first
291 check which paths are conflicting with 'git-status'
292 and after fixing them manually in your working tree, you would
293 stage the result as usual with 'git-add':
295 ------------
296 $ git status | grep unmerged
297 unmerged: hello.c
298 $ edit hello.c
299 $ git add hello.c
300 ------------
302 After resolving conflicts and staging the result, `git ls-files -u`
303 would stop mentioning the conflicted path.  When you are done,
304 run `git commit` to finally record the merge:
306 ------------
307 $ git commit
308 ------------
310 As with the case to record your own changes, you can use `-a`
311 option to save typing.  One difference is that during a merge
312 resolution, you cannot use `git commit` with pathnames to
313 alter the order the changes are committed, because the merge
314 should be recorded as a single commit.  In fact, the command
315 refuses to run when given pathnames (but see `-i` option).
318 DISCUSSION
319 ----------
321 Though not required, it's a good idea to begin the commit message
322 with a single short (less than 50 character) line summarizing the
323 change, followed by a blank line and then a more thorough description.
324 Tools that turn commits into email, for example, use the first line
325 on the Subject: line and the rest of the commit in the body.
327 include::i18n.txt[]
329 ENVIRONMENT AND CONFIGURATION VARIABLES
330 ---------------------------------------
331 The editor used to edit the commit log message will be chosen from the
332 GIT_EDITOR environment variable, the core.editor configuration variable, the
333 VISUAL environment variable, or the EDITOR environment variable (in that
334 order).  See linkgit:git-var[1] for details.
336 HOOKS
337 -----
338 This command can run `commit-msg`, `prepare-commit-msg`, `pre-commit`,
339 and `post-commit` hooks.  See linkgit:githooks[5] for more
340 information.
343 SEE ALSO
344 --------
345 linkgit:git-add[1],
346 linkgit:git-rm[1],
347 linkgit:git-mv[1],
348 linkgit:git-merge[1],
349 linkgit:git-commit-tree[1]
351 Author
352 ------
353 Written by Linus Torvalds <torvalds@osdl.org> and
354 Junio C Hamano <gitster@pobox.com>
359 Part of the linkgit:git[1] suite