Home Explore Blog CI



git

4th chunk of `Documentation/git-commit.adoc`
5ba98ae141d789c2a69ac4b419cc2882881efaf8557180550000000100000fa4
 `--allow-empty`, this
	command is primarily for use by foreign SCM interface scripts.

`--cleanup=<mode>`::
	Determine how the supplied commit message should be
	cleaned up before committing.  The '<mode>' can be `strip`,
	`whitespace`, `verbatim`, `scissors` or `default`.
+
--
`strip`::
	Strip leading and trailing empty lines, trailing whitespace,
	commentary and collapse consecutive empty lines.
`whitespace`::
	Same as `strip` except #commentary is not removed.
`verbatim`::
	Do not change the message at all.
`scissors`::
	Same as `whitespace` except that everything from (and including)
	the line found below is truncated, if the message is to be edited.
	"`#`" can be customized with `core.commentChar`.

		# ------------------------ >8 ------------------------

`default`::
	Same as `strip` if the message is to be edited.
	Otherwise `whitespace`.
--
+
The default can be changed by the `commit.cleanup` configuration
variable (see linkgit:git-config[1]).

`-e`::
`--edit`::
	Let the user further edit the message taken from _<file>_
	with `-F <file>`, command line with `-m <message>`, and
	from _<commit>_ with `-C <commit>`.

`--no-edit`::
	Use the selected commit message without launching an editor.
	For example, `git commit --amend --no-edit` amends a commit
	without changing its commit message.

`--amend`::
	Replace the tip of the current branch by creating a new
	commit. The recorded tree is prepared as usual (including
	the effect of the `-i` and `-o` options and explicit
	pathspec), and the message from the original commit is used
	as the starting point, instead of an empty message, when no
	other message is specified from the command line via options
	such as `-m`, `-F`, `-c`, etc.  The new commit has the same
	parents and author as the current one (the `--reset-author`
	option can countermand this).
+
--
It is a rough equivalent for:
------
	$ git reset --soft HEAD^
	$ ... do something else to come up with the right tree ...
	$ git commit -c ORIG_HEAD

------
but can be used to amend a merge commit.
--
+
You should understand the implications of rewriting history if you
amend a commit that has already been published.  (See the "RECOVERING
FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)

`--no-post-rewrite`::
	Bypass the `post-rewrite` hook.

`-i`::
`--include`::
	Before making a commit out of staged contents so far,
	stage the contents of paths given on the command line
	as well.  This is usually not what you want unless you
	are concluding a conflicted merge.

`-o`::
`--only`::
	Make a commit by taking the updated working tree contents
	of the paths specified on the
	command line, disregarding any contents that have been
	staged for other paths. This is the default mode of operation of
	`git commit` if any paths are given on the command line,
	in which case this option can be omitted.
	If this option is specified together with `--amend`, then
	no paths need to be specified, which can be used to amend
	the last commit without committing changes that have
	already been staged. If used together with `--allow-empty`
	paths are also not required, and an empty commit will be created.

`--pathspec-from-file=<file>`::
	Pass pathspec in _<file>_ instead of commandline args. If
	_<file>_ is exactly `-` then standard input is used. Pathspec
	elements are separated by _LF_ or _CR_/_LF_. Pathspec elements can be
	quoted as explained for the configuration variable `core.quotePath`
	(see linkgit:git-config[1]). See also `--pathspec-file-nul` and
	global `--literal-pathspecs`.

`--pathspec-file-nul`::
	Only meaningful with `--pathspec-from-file`. Pathspec elements are
	separated with _NUL_ character and all other characters are taken
	literally (including newlines and quotes).

`-u[<mode>]`::
`--untracked-files[=<mode>]`::
	Show untracked files.
+
--
The _<mode>_ parameter is optional (defaults to `all`), and is used to
specify the handling of untracked files; when `-u` is not used, the
default is `normal`, i.e. show untracked files

Title: Git Commit Options and Behavior
Summary
The git-commit command provides various options to control the commit process, including allowing empty commits, cleaning up commit messages, editing messages, and specifying paths to include or exclude, as well as options for handling untracked files and rewriting history, offering flexibility and customization for different use cases.