git 三个重要的状态

git 三个重要的状态

The Three States 
Now, pay attention. This is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: committed, modified, and staged. Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot. 
翻译: 
现在请注意,假如你希望git接下来的学习更轻松更顺利,那么你必须记住下面的事情. 
Git 有三个重要的状态: 
1. 提交的; 
2. 修改的(未commit); 
3. 缓存的 
提交:表示你修改的数据已经安全的保存到了本地仓库; 
修改:你修改了文件,但是还没有提交到本地仓库; 
缓存:表示你已经标记了修改的文件作为下次commit的一部分, 
如果你不标记,那么下次commit的时候,就不会提交这个文件.

This leads us to the three main sections of a Git project: the Git directory, the working directory, and the staging area. 
翻译:git项目分为三个主要的部分: 
1. git本地仓库; 
2. 工作区; 
3. 缓存区 
git的三种状态

The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.

The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.

The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the “index”, but it’s also common to refer to it as the staging area.

The basic Git workflow goes something like this:

You modify files in your working directory.

You stage the files, adding snapshots of them to your staging area.

You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.

If a particular version of a file is in the Git directory, it’s considered committed. If it has been modified and was added to the staging area, it is staged. And if it was changed since it was checked out but has not been staged, it is modified. In Git Basics, you’ll learn more about these states and how you can either take advantage of them or skip the staged part entirely.

我们结合git的常用操作来体会下git的三个状态

git checkout –

git checkout – 实际上就是把修改的文件恢复到本地仓库的状态

git reset

git reset 把commit的内容回滚到本地仓库上次提交的状态

git add

git add就是把工作区的文件添加到缓存区 
git tree

猜你喜欢

转载自hw1287789687.iteye.com/blog/2311824