Autogenerated HTML docs for v1.1.6-g5a79
[git.git] / git-commit.txt
1 git-commit(1)
2 =============
3
4 NAME
5 ----
6 git-commit - Record your changes
7
8 SYNOPSIS
9 --------
10 [verse]
11 'git-commit' [-a] [-i] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg>]
12            [-e] [--author <author>] [--] <file>...
13
14 DESCRIPTION
15 -----------
16 Updates the index file for given paths, or all modified files if
17 '-a' is specified, and makes a commit object.  The command
18 VISUAL and EDITOR environment variables to edit the commit log
19 message.
20
21 This command can run `commit-msg`, `pre-commit`, and
22 `post-commit` hooks.  See link:hooks.html[hooks] for more
23 information.
24
25 OPTIONS
26 -------
27 -a|--all::
28         Update all paths in the index file.  This flag notices
29         files that have been modified and deleted, but new files
30         you have not told git about are not affected.
31
32 -c or -C <commit>::
33         Take existing commit object, and reuse the log message
34         and the authorship information (including the timestamp)
35         when creating the commit.  With '-C', the editor is not
36         invoked; with '-c' the user can further edit the commit
37         message.
38
39 -F <file>::
40         Take the commit message from the given file.  Use '-' to
41         read the message from the standard input.
42
43 --author <author>::
44         Override the author name used in the commit.  Use
45         `A U Thor <author@example.com>` format.
46
47 -m <msg>::
48         Use the given <msg> as the commit message.
49
50 -s|--signoff::
51         Add Signed-off-by line at the end of the commit message.
52
53 -v|--verify::
54         Look for suspicious lines the commit introduces, and
55         abort committing if there is one.  The definition of
56         'suspicious lines' is currently the lines that has
57         trailing whitespaces, and the lines whose indentation
58         has a SP character immediately followed by a TAB
59         character.  This is the default.
60
61 -n|--no-verify::
62         The opposite of `--verify`.
63
64 -e|--edit::
65         The message taken from file with `-F`, command line with
66         `-m`, and from file with `-C` are usually used as the
67         commit log message unmodified.  This option lets you
68         further edit the message taken from these sources.
69
70 -i|--include::
71         Instead of committing only the files specified on the
72         command line, update them in the index file and then
73         commit the whole index.  This is the traditional
74         behaviour.
75
76 --::
77         Do not interpret any more arguments as options.
78
79 <file>...::
80         Commit only the files specified on the command line.
81         This format cannot be used during a merge, nor when the
82         index and the latest commit does not match on the
83         specified paths to avoid confusion.
84
85 If you make a commit and then found a mistake immediately after
86 that, you can recover from it with gitlink:git-reset[1].
87
88
89 Discussion
90 ----------
91
92 `git commit` without _any_ parameter commits the tree structure
93 recorded by the current index file.  This is a whole-tree commit
94 even the command is invoked from a subdirectory.
95
96 `git commit --include paths...` is equivalent to
97
98         git update-index --remove paths...
99         git commit
100
101 That is, update the specified paths to the index and then commit
102 the whole tree.
103
104 `git commit paths...` largely bypasses the index file and
105 commits only the changes made to the specified paths.  It has
106 however several safety valves to prevent confusion.
107
108 . It refuses to run during a merge (i.e. when
109   `$GIT_DIR/MERGE_HEAD` exists), and reminds trained git users
110   that the traditional semantics now needs -i flag.
111
112 . It refuses to run if named `paths...` are different in HEAD
113   and the index (ditto about reminding).  Added paths are OK.
114   This is because an earlier `git diff` (not `git diff HEAD`)
115   would have shown the differences since the last `git
116   update-index paths...` to the user, and an inexperienced user
117   may mistakenly think that the changes between the index and
118   the HEAD (i.e. earlier changes made before the last `git
119   update-index paths...` was done) are not being committed.
120
121 . It reads HEAD commit into a temporary index file, updates the
122   specified `paths...` and makes a commit.  At the same time,
123   the real index file is also updated with the same `paths...`.
124
125 `git commit --all` updates the index file with _all_ changes to
126 the working tree, and makes a whole-tree commit, regardless of
127 which subdirectory the command is invoked in.
128
129
130 Author
131 ------
132 Written by Linus Torvalds <torvalds@osdl.org> and
133 Junio C Hamano <junkio@cox.net>
134
135
136 GIT
137 ---
138 Part of the gitlink:git[7] suite