Git workspace, staging area and repository
Basic concepts
Let’s first understand the concepts of Git workspace, staging area and repository
Workspace: It’s what you can see on your computer Table of contents.
Temporary storage area: called stage in English,
or index. It is generally stored in the index file (.git/index) under the "git directory", so we sometimes call the temporary storage area the index (index).
Repository: There is a hidden directory .git in the workspace. This is not the workspace, but the Git repository.
The following figure shows the relationship between the workspace, the staging area in the repository and the repository:
The left side of the figure is the workspace and the right side is the repository. The area marked "index" in the repository is the staging area (stage, index), and the area marked "master" is master
The directory tree represented by the branch.
We can see in the picture that "HEAD" is actually a "cursor" pointing to the master branch. So where HEAD appears in the command shown in the picture, you can use master
to replace.
The area identified by objects in the picture is the Git object library, which is actually located in ".git/objects"
directory, which contains various objects and content created.
When executing "git add" on files modified (or added) in the workspace
When executing the command, the directory tree in the temporary storage area is updated, and at the same time, the modified (or newly added) file contents in the workspace are written to a new object in the object library, and the ID of the object is recorded in the temporary storage area. File indexing.
When a commit operation (git commit) is performed, the directory tree in the staging area is written to the version library (object library), and the master branch will be updated accordingly. i.e. master
The directory tree pointed to is the directory tree of the temporary storage area at the time of submission.
When the "git reset HEAD" command is executed, the directory tree in the staging area will be rewritten and replaced by the directory tree pointed to by the master branch, but the workspace will not be affected.
When the "git rm --cached
When executing "git checkout ." or "git checkout --
When executing the "git checkout HEAD ." or "git checkout HEAD
The above is the detailed explanation of the workspace, temporary storage area and repository of the Git tutorial. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!