Hongmu Notes

git commit

Submit the file to the repository

100% Browser local processing 0 Data upload

Common examples

Submit the temporarily stored files to the repository, accompanied by submission instructions.

git commit {{[-m|--message]}} "{{信息}}"

Submit the files for temporary storage and read the accompanying submission information from the specified files.

git commit {{[-F|--file]}} {{路径/到/提交信息文件}}

Automatically temporarily store and submit all modified and deleted files along with the submission information

git commit {{[-a|--all]}} {{[-m|--message]}} "{{信息}}"

Submit the files for temporary storage and sign them using the specified GPG key (if no parameters are specified, use the settings in the configuration file).

git commit {{[-S|--gpg-sign]}} {{密钥id}} {{[-m|--message]}} "{{信息}}"

Append the currently staged changes to the most recent commit and update its hash value.

git commit --amend

Submit only the specified (temporarily stored) files

git commit {{路径/到/文件1 路径/到/文件2 ...}}

Create and commit even without a temporary file

git commit {{[-m|--message]}} "{{信息}}" --allow-empty

Tip: curly braces{{…}}It is the parameter that needs to be replaced (path, file name, etc.); the command is only executed in the local terminal, and this site does not save any input.

English original text comparison

Expand English instructions and examples (source tldr-pages)

Commit files to the repository. More information

Open an editor to write a message and commit staged files to the repository

git commit

Commit staged files to the repository with the specified message

git commit {{[-m|--message]}} "{{message}}"

Commit staged files with a message read from a file

git commit {{[-F|--file]}} {{path/to/commit_message_file}}

Auto stage all modified and deleted files and commit

git commit {{[-a|--all]}} {{[-m|--message]}} "{{message}}"

Commit staged files and sign them with the specified GPG key (or the one defined in the configuration file if no `key_id` is specified)

git commit {{[-S|--gpg-sign]}} {{key_id}} {{[-m|--message]}} "{{message}}"

Update the last commit by adding the currently staged changes, changing the commit's hash and open an editor to change the message

git commit --amend

Commit only specific (already staged) files

git commit {{path/to/file1 path/to/file2 ...}}

Create a commit with the specified message and description

git commit {{[-m|--message]}} "{{message}}" {{[-m|--message]}} "{{description}}"

command information

command namegit commit
PurposeSubmit the file to the repository
Applicable platforms通用
Number of examples7 Article
Official documentationhttps://git-scm.com/docs/git-commit
Data sourcetldr-pages(CC-BY-4.0)· Community Chinese Translation

FAQ

git commit What does the command do?

Submit the file to the repository

git commit How to use it?

Pages listed by scene7Commonly used examples: Each example first explains the purpose, and then gives a complete command that can be directly copied (the parameters that need to be replaced are in the curly brackets).

git commit What are the most commonly used operations?

Submit the temporarily stored files to the repository, accompanied by submission instructions.:git commit {{[-m|--message]}} "{{信息}}"

What do the curly braces in the command mean?

curly braces{{…}}Indicates that you need to replace it with your own value, such as path and file name; square brackets for parameters with the same name (such as[-C|--directory]) indicates optional writing.