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