About version control
What is version control?
Version control is a system that records changes in the contents of one or more files for future review of revisions to a particular version.
Types of version control system
Local version control system
Many people are accustomed to copying the entire project directory to save different versions, and may change their names and add backup events to make a difference. The only benefit of doing this is simplicity, but it’s particularly error-prone, sometimes confusing the working directory, accidentally writing the wrong file or overwriting the unexpected file.
In order to solve this problem, many local version control systems have been developed long ago, mostly using some simple database to record the differences in the past updates of files.
One of the most popular is called RCS. It works by saving the set of patches on the hard disk (patches refer to changes before and after revision); by applying all the patches, you can recalculate the contents of each version of the file.
Centralized version control system
How can developers of different systems work together? Therefore, centralized version control system, called CVCS, came into being. Such systems have a single centrally managed server that holds all revised versions of files, and people who work together connect to the server through the client and remove them.Latest documents or submissions for updates have been standard practice for version control systems for many years.
This approach has brought a lot of benefits, especially when compared with the old local VCS. Now everyone can see to a certain extent what other people on the project are doing, and administrators can easily control the rights of each developer and manage a CVCS much more than they do on each client.It’s easy and easy to protect the local database.
The disadvantage of this is that the central server has a single point of failure. At this point, no one can submit updates or work together. If the disk is damaged and there is no proper backup, all the data will be lost — including the change history of the entire project, leaving only a separate snapshot that people keep on their machines.
Distributed version control system DVCS
In such systems, the client does not just extract a snapshot of the latest version of the file, but mirrors the code warehouse completely. As a result, any coordinated server fails and can be recovered from any mirrored local repository afterwards. Because every clone operation is actually done.It’s a complete backup of the code repository.
Such systems can be specified to interact with a number of different remote code repositories.
Gitbrief introduction
GitBorn in a time of great dispute and great innovation.
LinuxKernel open source projects, due to too much maintenance work, in 2002, began using a proprietary distributed management system BitKeeper to manage and maintain code.
2005In 1997, the partnership between the commercial company that developed BitKeeper and the Linux kernel open source community ended, and the community was no longer allowed to use BitKeeper for free. Forcing Linux open source community to develop its own version system. Git was born.
GitBasics
GitDirect recording of snapshots, rather than differences.
GitThe main difference between other version control systems is the way Git treats data.
Conceptions distinguish most other systems from storing information in a file changing list. Such systems view the information they hold as a set of basic files and the differences that each file accumulates over time.
GitDo not treat or save data in the above way. On the contrary, GIt is more like looking at data as a set of snapshots of small file systems. Every time you submit an update, or save the status of the project in Git, it makes a snapshot of the entire file at the time and saves the index of the snapshot. For efficiency, such asIf the file is not modified, Git will no longer re-store the file, leaving only one link to the previously stored file. Git treats data more like a snapshot stream.
Therefore, Git reconsidered many aspects of the previous generation of version control system.
###GitIt’s more like a small file system.
It provides many super tools built on this basis, not just a simple VCS.
Almost all operations are performed locally.
Most operations in Git require only access to local files and resources, and generally do not require information from other computers on the network. Because the local disk has a complete history of the project, most operations seem to be completed instantaneously.
GitGuarantee integrity
GitAll data in the database is calculated before storage, and is then referenced by checksum. This means that it is impossible to change any file content or directory content when Git is unaware. This function is built on the bottom of Git and constitutes an indispensable part of Git philosophy. If the message is lost or damaged during the transmission processGit can be found.
GitThe mechanism used to compute checksums is called SHA-1 (hash, Hashi). This is a string of 40 hexadecimal characters, calculated based on the contents or directory structure of the files in Git.
In fact, the information stored in Git databases is indexed by the hash value of the file content, not by the file name.
GitGenerally only data is added.
The Git operation you execute almost adds data to the Git database. It makes it very difficult for Git to perform any irreversible operation, or let it erase data in any way. Like other VCSs, it is possible to lose or mess up changes when updates are not submitted; but once they are submitted to Git, it is difficultTo lose data again.
Three states
The file may be in three states in Git.
- Submission:Indicates that the data file has been safely stored in the local database.
- Modified:The file has been modified, but it has not been saved to the database.
- Have been suspended:The current version of a modified file is marked to be included in the next submitted snapshot.
This leads to the concept of the three working areas of the Git project:
- GitWarehouse
- working directory
- staging area
