下面是git的一些基本概念
The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data. Conceptually, most other systems store information as a list of file-based changes. These other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as delta-based version control).
一个重要的区分是: 他们看待数据的方式不同。
其他大部分版本控制方式经常被称为“基于增量的版本控制”。 如图,当文件变更时,版本控制系统会将每次的变更保存。
Git doesn’t think of or store its data this way. Instead, Git thinks of its data more like a series of snapshots of a miniature filesystem. With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored. Git thinks about its data more like a stream of snapshots.
而git并不是。git把文件视为一系列迷你文件系统的快照。文件的每一次变更,git都会存储一个快照,当然假如文件没有变更,那就只存储一个之前的引用就可以了。
git大部分操作都是本地完成,所以可以非常快,即使没有网络也可以工作。
Git使用SHA-1哈希来校验文件,对文件的任何更改都会被检测到。
事实上,Git存储信息的方式不是通过文件,而是通过内容的哈希值。
这样使得任何操作都可以撤销。
这三种状态也就划分了Git项目的三个部分: 工作目录、暂存区、.git目录
工作目录是从项目中一个版本导出来的。这些文件从Git目录中压缩库中提取出来,放在磁盘上供使用和修改。
暂存区是一个文件。他存储下一次提交的内容信息。
.git目录中存储着所有的数据库,是Git中最重要的部分。
一个基本的Git工作流是这样的: