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