In git, staged is used to indicate the status of a file, which means temporary storage status. Changes to files or directories in this status will not affect the status of the warehouse. They are also invisible when committing. When it arrives, execute "git commit" to synchronize the changes to the library. At this time, the files in the library and the local files become consistent again.
The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.
What does staged mean in git
There are roughly 4 states of files in the folder where the git library is located
Untracked: This file is in the folder, but has not been added to the git library and does not participate in version control. The status changes to Staged through git add.
Unmodify: The file has been stored in the library and has not been modified, that is, the file snapshot content in the repository is exactly the same as that in the folder. This type of file has two places. If it is modified, it becomes Modified. If you use git When rm is moved out of the repository, it becomes an Untracked file
Modified: The file has been modified, just modified, and no other operations have been performed. This file also has two places, which can be accessed through git add The staged state is temporarily saved. Use git checkout to discard the modifications and return to the unmodify state. This git checkout takes the file from the library and overwrites the current modifications
Staged: Staging state. Execute git commit synchronizes the modifications to the library. At this time, the files in the library and the local files become consistent again, and the files are in the Unmodify state. Execute git reset HEAD filename to cancel the temporary save, and the file status is Modified
Change from untracked state to staged state
We can directly change a file that is not included in version management to staged state through git add
Change from modified state to staged state
When your file is modified, you can still change the modified file to staged state through git add
Include all files in the current directory into the staged state
If there are newly created files (in the untracked state) under the current working tree, and there are files that have been modified (in the modified state) status), at this time we can change all files to staged status through git add -A
Recommended learning: "Git Tutorial"
The above is the detailed content of What does staged mean in git?. For more information, please follow other related articles on the PHP Chinese website!