Git-Runoob: Git work area, staging area and repository

ylbtech-Git-Runoob: Git work area, staging area and repository

 

1. Back to top
1、

Git work area, staging area and repository


basic concepts

We first understand under Git workspace, the repository concept and staging area

  • Workspace: what you can see in the computer catalog.
  • Temporary Area: English called stage, or index. Usually stored in the ".git directory under" index file (.git / index) in the next , so we put the staging area is sometimes called the index (index).
  • Repository: workspace has a hidden directory .git, this is not the work area, but Git repository.

The following figure shows the relationship between the workspace, the repository of the staging area and the repository:

The figure on the left in the work area on the right side for the repository. In the repository labeled "index" of the region is the staging area (stage, index), marked as "master" is the master branch of the tree represents.

At this time we can see the figure "HEAD" is actually a master branch point "cursor." HEAD command where it appears in the illustration may be replaced with the master.

Area objects identified the figure as Git object library, actually located ".git / objects" directory, which contains a variety of objects and content creation.

When the work area to modify (or new) files execute "git add" command, the directory tree is updated staging area while the work area to modify (or add) the contents of a file is written to object library the new object, and the object ID is recorded in a temporary area of ​​the file index.

When performing a commit (git commit), the directory tree in the temporary area writing to the repository (object library) in, master branch will be updated accordingly. Temporary directory tree area ie master point of the directory tree is submitted.

When performing "git reset HEAD" command, tree staging area will be rewritten, is replaced by the master branch points of the tree, but the work area is not affected.

When performing "git rm --cached <file>" command deletes files directly from the staging area, the work area is not to make a change.

When performing "git checkout." Or "git checkout - <file>" command, it will replace all or a workspace file with the specified file temporary storage area. This operation is very dangerous, clears the workspace changes are not added to the staging area.

When performing "git checkout HEAD." Or "git checkout HEAD <file>" command, and replaces the temporary storage area in the work area of ​​the master file of all branch HEAD points or part of the file. This command is very dangerous, because the changes will not only clear the work area uncommitted changes to the staging area will be cleared uncommitted.

2、
2. Return to top
 
3. Back to top
 
4. Top
 
5. Top
1、
2、
 
6. Back to top
 
warn Author: ylbtech
Source: http://ylbtech.cnblogs.com/
This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page, otherwise We reserve the right to pursue legal responsibilities.

Guess you like

Origin www.cnblogs.com/storebook/p/11718042.html