Robin Hu的专栏

语法

git commit [-a | –interactive | –patch] [-s] [-v] [-u<mode>] [–amend] [–dry-run] [(-c | -C | –fixup | –squash) <commit>] [-F <file> | -m <msg>] [–reset-author] [–allow-empty] [–allow-empty-message] [–no-verify] [-e] [–author=<author>] [–date=<date>] [–cleanup=<mode>] [–status | –no-status] [-i | -o] [–] [<file>…]

DESCRIPTION

Stores the current contents of the index in a new commit along with a log message from the user describing the changes.

The content to be added can be specified in several ways:

by usinggit addto incrementally "add" changes to the index before using thecommitcommand (Note: even modified files must be "added");

by usinggit rmto remove files from the working tree and the index, again before using thecommitcommand;

by listing files as arguments to thecommitcommand, in which case the commit will ignore changes staged in the index, and instead record the current content of the listed files (which must already be known to git);

by using the -a switch with thecommitcommand to automatically "add" changes from all known files (i.e. all files that are already listed in the index) and to automatically "rm" files in the index that have been removed from the working tree, and then perform the actual commit;

by using the –interactive or –patch switches with thecommitcommand to decide one by one which files or hunks should be part of the commit, before finalizing the operation. See the`Interactive Mode` section ofgit-add(1)to learn how to operate these modes.

The–dry-runoption can be used to obtain a summary of what is included by any of the above for the next commit by giving the same set of parameters (options and paths).

If you make a commit and then find a mistake immediately after that, you can recover from it withgit reset.

OPTIONS

-a–all

Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.

-p–patch

Use the interactive patch selection interface to chose which changes to commit. Seegit-add(1)for details.

-C <commit>–reuse-message=<commit>

Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.

-c <commit>–reedit-message=<commit>

Like-C, but with-cthe editor is invoked, so that the user can further edit the commit message.

–fixup=<commit>

Construct a commit message for use withrebase –autosquash. The commit message will be the subject line from the specified commit with a prefix of "fixup! ". Seegit-rebase(1)for details.

–squash=<commit>

Construct a commit message for use withrebase –autosquash. The commit message subject line is taken from the specified commit with a prefix of "squash! ". Can be used with additional commit message options (-m/-c/-C/-F). Seegit-rebase(1)for details.

–reset-author

When used with -C/-c/–amend options, or when committing after a a conflicting cherry-pick, declare that the authorship of the resulting commit now belongs of the committer. This also renews the author timestamp.

–short

When doing a dry-run, give the output in the short-format. Seegit-status(1)for details. Implies–dry-run.

–porcelain

When doing a dry-run, give the output in a porcelain-ready format. Seegit-status(1)for details. Implies–dry-run.

-z

When showingshortorporcelainstatus output, terminate entries in the status output with NUL, instead of LF. If no format is given, implies the–porcelainoutput format.

-F <file>–file=<file>

Take the commit message from the given file. Use-to read the message from the standard input.

–author=<author>

Override the commit author. Specify an explicit author using the standardA U Thor <author@example.com>format. Otherwise <author> is assumed to be a pattern and is used to search for an existing commit by that author (i.e. rev-list –all -i –author=<author>); the commit author is then copied from the first such commit found.

–date=<date>

Override the author date used in the commit.

-m <msg>–message=<msg>

Use the given <msg> as the commit message.

-t <file>–template=<file>

Use the contents of the given file as the initial version of the commit message. The editor is invoked and you can make subsequent changes. If a message is specified using the-mor-Foptions, this option has no effect. This overrides thecommit.templateconfiguration variable.

-s–signoff

Add Signed-off-by line by the committer at the end of the commit log message.

-n–no-verify

This option bypasses the pre-commit and commit-msg hooks. See alsogithooks(5).

–allow-empty联系朋友别欠费,天空辽阔任你飞,再多困难别后退! “

Robin Hu的专栏

相关文章:

你感兴趣的文章:

标签云: