Documentation / git-commit.txton commit builtin-commit: add --date option (02b47cd)
   1git-commit(1)
   2=============
   3
   4NAME
   5----
   6git-commit - Record changes to the repository
   7
   8SYNOPSIS
   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>...]
  15
  16DESCRIPTION
  17-----------
  18Stores the current contents of the index in a new commit along
  19with a log message from the user describing the changes.
  20
  21The content to be added can be specified in several ways:
  22
  231. 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");
  26
  272. by using 'git-rm' to remove files from the working tree
  28   and the index, again before using the 'commit' command;
  29
  303. 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);
  34
  354. 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;
  40
  415. 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'.
  44
  45The `--dry-run` option can be used to obtain a
  46summary of what is included by any of the above for the next
  47commit by giving the same set of parameters (options and paths).
  48
  49If you make a commit and then find a mistake immediately after
  50that, you can recover from it with 'git-reset'.
  51
  52
  53OPTIONS
  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.
  60
  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.
  66
  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.
  71
  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.
  76
  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.
  81
  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.
  87
  88--date=<date>::
  89        Override the author date used in the commit.
  90
  91-m <msg>::
  92--message=<msg>::
  93        Use the given <msg> as the commit message.
  94
  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.
 102
 103-s::
 104--signoff::
 105        Add Signed-off-by line by the committer at the end of the commit
 106        log message.
 107
 108-n::
 109--no-verify::
 110        This option bypasses the pre-commit and commit-msg hooks.
 111        See also linkgit:githooks[5].
 112
 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.
 118
 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.
 128
 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.
 135
 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.
 145+
 146--
 147It 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
 152
 153------
 154but can be used to amend a merge commit.
 155--
 156+
 157You should understand the implications of rewriting history if you
 158amend a commit that has already been published.  (See the "RECOVERING
 159FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)
 160
 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.
 167
 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.
 179
 180-u[<mode>]::
 181--untracked-files[=<mode>]::
 182        Show untracked files (Default: 'all').
 183+
 184The mode parameter is optional, and is used to specify
 185the handling of untracked files. The possible options are:
 186+
 187--
 188        - 'no'     - Show no untracked files
 189        - 'normal' - Shows untracked files and directories
 190        - 'all'    - Also shows individual files in untracked directories.
 191--
 192+
 193See linkgit:git-config[1] for configuration variable
 194used to change the default for when the option is not
 195specified.
 196
 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 '#'.
 203
 204-q::
 205--quiet::
 206        Suppress commit summary message.
 207
 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.
 212
 213\--::
 214        Do not interpret any more arguments as options.
 215
 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.
 222
 223
 224EXAMPLES
 225--------
 226When recording your own work, the contents of modified files in
 227your working tree are temporarily stored to a staging area
 228called the "index" with 'git-add'.  A file can be
 229reverted back, only in the index but not in the working tree,
 230to that of the last commit with `git reset HEAD -- <file>`,
 231which effectively reverts 'git-add' and prevents the changes to
 232this file from participating in the next commit.  After building
 233the state to be committed incrementally with these commands,
 234`git commit` (without any pathname parameter) is used to record what
 235has been staged so far.  This is the most basic form of the
 236command.  An example:
 237
 238------------
 239$ edit hello.c
 240$ git rm goodbye.c
 241$ git add hello.c
 242$ git commit
 243------------
 244
 245Instead of staging files after each individual change, you can
 246tell `git commit` to notice the changes to the files whose
 247contents are tracked in
 248your working tree and do corresponding `git add` and `git rm`
 249for you.  That is, this example does the same as the earlier
 250example if there is no other change in your working tree:
 251
 252------------
 253$ edit hello.c
 254$ rm goodbye.c
 255$ git commit -a
 256------------
 257
 258The command `git commit -a` first looks at your working tree,
 259notices that you have modified hello.c and removed goodbye.c,
 260and performs necessary `git add` and `git rm` for you.
 261
 262After staging changes to many files, you can alter the order the
 263changes are recorded in, by giving pathnames to `git commit`.
 264When pathnames are given, the command makes a commit that
 265only records the changes made to the named paths:
 266
 267------------
 268$ edit hello.c hello.h
 269$ git add hello.c hello.h
 270$ edit Makefile
 271$ git commit Makefile
 272------------
 273
 274This makes a commit that records the modification to `Makefile`.
 275The changes staged for `hello.c` and `hello.h` are not included
 276in the resulting commit.  However, their changes are not lost --
 277they are still staged and merely held back.  After the above
 278sequence, if you do:
 279
 280------------
 281$ git commit
 282------------
 283
 284this second commit would record the changes to `hello.c` and
 285`hello.h` as expected.
 286
 287After a merge (initiated by 'git-merge' or 'git-pull') stops
 288because of conflicts, cleanly merged
 289paths are already staged to be committed for you, and paths that
 290conflicted are left in unmerged state.  You would have to first
 291check which paths are conflicting with 'git-status'
 292and after fixing them manually in your working tree, you would
 293stage the result as usual with 'git-add':
 294
 295------------
 296$ git status | grep unmerged
 297unmerged: hello.c
 298$ edit hello.c
 299$ git add hello.c
 300------------
 301
 302After resolving conflicts and staging the result, `git ls-files -u`
 303would stop mentioning the conflicted path.  When you are done,
 304run `git commit` to finally record the merge:
 305
 306------------
 307$ git commit
 308------------
 309
 310As with the case to record your own changes, you can use `-a`
 311option to save typing.  One difference is that during a merge
 312resolution, you cannot use `git commit` with pathnames to
 313alter the order the changes are committed, because the merge
 314should be recorded as a single commit.  In fact, the command
 315refuses to run when given pathnames (but see `-i` option).
 316
 317
 318DISCUSSION
 319----------
 320
 321Though not required, it's a good idea to begin the commit message
 322with a single short (less than 50 character) line summarizing the
 323change, followed by a blank line and then a more thorough description.
 324Tools that turn commits into email, for example, use the first line
 325on the Subject: line and the rest of the commit in the body.
 326
 327include::i18n.txt[]
 328
 329ENVIRONMENT AND CONFIGURATION VARIABLES
 330---------------------------------------
 331The editor used to edit the commit log message will be chosen from the
 332GIT_EDITOR environment variable, the core.editor configuration variable, the
 333VISUAL environment variable, or the EDITOR environment variable (in that
 334order).  See linkgit:git-var[1] for details.
 335
 336HOOKS
 337-----
 338This command can run `commit-msg`, `prepare-commit-msg`, `pre-commit`,
 339and `post-commit` hooks.  See linkgit:githooks[5] for more
 340information.
 341
 342
 343SEE ALSO
 344--------
 345linkgit:git-add[1],
 346linkgit:git-rm[1],
 347linkgit:git-mv[1],
 348linkgit:git-merge[1],
 349linkgit:git-commit-tree[1]
 350
 351Author
 352------
 353Written by Linus Torvalds <torvalds@osdl.org> and
 354Junio C Hamano <gitster@pobox.com>
 355
 356
 357GIT
 358---
 359Part of the linkgit:git[1] suite