Home >Development Tools >git >What is the Git staging area?
This article mainly introduces to you what Git temporary storage area is.
GIT, a distributed version control system, is an important tool commonly used by programmers, which can greatly improve the efficiency of our project work. Well, in the previous article, I have given you a detailed introduction to What is Git, Initial use of Git and How to create a repository with Git, friends who need it You can refer to it first.
This section will focus on introducing Git temporary storage area.
Below we will explain Git temporary storage area through specific examples.
First, we open the Git command line in the test directory we created previously:
Through Use the git status command to view the content status of the repository. You can find that there are no files in the current directory.
Then we first manually create a 123.txt file in the test directory, and then check the status through the git status command.
You can see the red marked 123.txt from the above picture, indicating that this state is still in the work area and not in the temporary storage area .
When we use the command git add 123.txt, it means that the file is added from the workspace to the temporary storage area. As shown in the figure below, there is a new file: 123. txt file is added to the temporary storage area.
But it has not been submitted yet. When the git commit -m "Create 123.txt file" command is executed, the file will be transferred from the temporary area to the master branch. Above, when you check the status as shown in the figure below, you cannot see what is in the temporary storage area.
Summary:
Git has three important areas:
Workspace: A simple understanding is that a certain folder (assumed to be test) needs to be versioned. This folder has some special features - there is an additional .git hidden folder
version library : The .git folder under the test folder is the version library.
Temporary storage area: The temporary storage area can be understood as a virtual workspace. This virtual workspace will track file changes in the workspace (operations such as additions, deletions, modifications, etc.). This workspace is located in the index directory under the .git folder. Unless it is submitted directly, bypassing the staging area, if Git wants to submit changes, it must store the changes in the staging area before committing. Each submission is a snapshot of the file corresponding to the temporary storage area.
This article is an introduction to the Git temporary storage area. I believe everyone already has a certain understanding of the git temporary storage area. I hope that the introduction in this section will be helpful to friends in need!
The above is the detailed content of What is the Git staging area?. For more information, please follow other related articles on the PHP Chinese website!