This article is based on the preparation and thinking notes made by Scott Chacon, author of Pro Git.
For more information about how to download the Chinese version of Pro Git, see
1. File cycle managed by GIT
1. The newly added file or folder is in the untracked State, meaning that this file is not found in git version management.
You can use git add to add this file to git for management, and then it will be in the stage state in tracked.
If it is a new git clone or git init file, it is in the unmodified state in the tracked state.
Note 1: when a new file is added, the untracked status is as follows:
NOTE 2: After you add a file to git by using git add <File Name>, the file is in the staged state under tracked.
2. Under git management, the status is tracked, including unmodified, modified, and staged.
3. the unmodified state indicates that the local file is consistent with the last commit of the file in the version library.
4. Once the file is modified, the file content is inconsistent with the last submitted content of the file in the version library, and the status changes to modified. You can use git add <File> to stage files.
For files after stage, you can use git commit <File> to submit the file or git reset HEAD <File> to cancel the stage state.
5. If a file has been stage and is modified again, the state is partial stage and partial modified. If commit is used, the section of the stage is submitted.
6. git add has multiple functions. You can track untracked files, perform the modified file stage, and perform the stage of the files modified by conflict in merge.
Q: Why is there a stage status? Isn't it very troublesome to modify the file to make the stage and then commit?
My answer: commit is a commit of all stage files, and there is no commit for a file.
In general, a single commit is used to complete a version of snapshot. You can modify a file to the stage, or you can modify many files to stage together. Stage is like a box where all content to be commit is loaded. Then commit the packed content.
If the modified file can be submitted directly, you can use git commit-a for automatic stage, that is, to submit all modifications automatically.