The Git commit file command is used to save code changes to the local warehouse. The usage method is as follows: add the files to be submitted to the staging area (git add); commit the changes in the staging area and provide submission message (git commit -m); optionally commit a specific range of changes (git commit -p); special uses include modifying the commit message (git commit --amend) and skipping commit hooks (git commit --no-verify) .
How to use the Git commit file command
The Git commit file command is used to save the code changes made to the local warehouse. The specific usage is as follows:
1. Prepare to submit
2. Add files to the staging area
Use the git add
command to add the files to be submitted to the staging area. You can add a single file or multiple files. For example:
git add filename
Add a single filegit add .
Add all changed files in the current directory3. Submit changes
Use the git commit
command to submit the changes in the staging area Change. When committing, you need to provide a commit message describing the code changes made. For example:
git commit -m "Add new feature"
4. Select the submission scope
git commit -p
command. This will open an interactive interface that allows you to select rows of changes to commit. 5. Special usage
git commit --amend -m " Modify the commit message "
git commit -n
git commit --no-verify
Example
Assume you are in my- There are some code changes made in the project
directory, to commit these changes you can follow these steps:
cd my-project
git add filename1 filename2
The above is the detailed content of How to use the git commit file command. For more information, please follow other related articles on the PHP Chinese website!