Submitting a Git file involves three steps: Use git add to add the file to the staging area. Use git commit -m "commit message" to commit the file. Use git push origin
to push files to the remote repository.
How to use Git to submit files
Step 1: Add files to the staging area
Before submitting files, you need to add them to the staging area. This ensures that only the files you wish to submit are submitted. To add a file to the staging area, use the following command:
<code>git add <文件名></code>
Step 2: Submit the file
Once the file has been added to the staging area, you can use The following command commits them:
<code>git commit -m "<提交信息>"</code>
The commit message is a comment briefly describing the changes.
Step 3: Push the file to the remote warehouse
After submitting the file, you can also push it to the remote warehouse to share it with others. To do this, use the following command:
<code>git push origin <分支名称></code>
where origin
is the name of the remote repository and branchname
is the target branch to which you want to push the file.
Additional Notes:
<code>git add .</code>
This will Add all files in the current directory to the staging area.
-a
flag to automatically add all tracked files to the staging area and submit: <code>git commit -a -m "<提交信息>"</code>
<code>git commit --amend -m "<新提交信息>"</code>
The above is the detailed content of How to commit files in git. For more information, please follow other related articles on the PHP Chinese website!