1.1 Getting Started-about version control
This chapter will tell you how to get started with git. We'll talk about the background of the version Control tool as a start, and then we'll continue to explain how to run git on your system and eventually let it run and use it. Finally, at the end of this chapter you should understand why Git is so popular, why you should use it, and why you should use it immediately. about versioning what is "versioning", and why do you care about this problem? Versioning is a system that records file changes and then you can roll back files to a specific version, for example, in the example shown in this book, we are only versioning the text files that save the source code of the software, but in fact, you can version control any type of file.
If you are a graphic designer or web designer and want to save every version of the picture and layout (which is perhaps the most desired feature), using a version control System,vcs will be a wise choice. It allows you to return the file to its previous state, return the entire project to its previous state, compare the details of the changes to the file, and find out who made the last change to identify the cause of the weird problem. Who introduced the issue, when the problem was introduced, and other more versatile use of the version control system often means that you have broken files or deleted files, and you can easily recover them. In addition, you can achieve this effect with minimal extra work overhead. local version control system Many people's version control method is to copy files to another path (if they are smart enough, perhaps also use time to annotate), so the only benefit is simple. When you're copying files, it's easy to get some surprises, maybe you'll forget the path you want to save, and you won't be able to undo the recovery once you've lost the data in the wrong file. To solve this problem, engineers developed a local version control VCs a long time ago, which has a small database that can keep all the changes under version control.
Figure 1-1. Local version control. There is a more popular version control system called RCS, which is still distributed in many computers today. Even after the popular Mac OSX has installed development tools, you can also use the RCS command. It works basically to save and manage file patches. A file patch is a special-format text file that records changes in content before and after the corresponding file revision. So, based on each revised patch, RCS can calculate the file contents of each version by constantly patching.
Centralized version control system
The main problem people face next is that people need to work together in the system. In order to solve this problem, a centralized version control system (CVCSS) has been developed centralized For example, cvs,subversion and perfoce These systems have a server that contains all versions of the files, and the people who work together connect to the server through the client, take out the latest files, or submit the updated content. This has been a standard practice for version control systems for many years. Picture 1-2. Centralized version control system
This setup offers many advantages, especially over local VCSs. For example, everyone knows to a certain degree what everyone else on the project is doing. Administrators has fine-grained control over who can does what; And it's far from easier to administer a CVCS than it's to the deal with the local databases on every client.
However, this setup also have some serious downsides. The most obvious are the single point of failure the centralized server represents. If the server goes down for a hour, then during the hour nobody can collaborate at all or save versioned changes to any Thing they ' re working on. If the hard disk The central database was on becomes corrupted, and proper backups haven ' t been kept, you lose absolutely E Verything–the entire history of the project except whatever a snapshots people happen to has on their local machin Es. Local VCS systems suffer from this same problem–whenever Y has the entire history of the project OU risk losing everything. distributed Version Control Systems
This is the where distributed Version Control Systems (dvcss) step in. In a DVCS (such as Git, Mercurial, Bazaar or DARCS), clients don ' t just check out the latest snapshot of the Files:they F Ully Mirror the repository. Thus If any server dies, and these systems were collaborating via it, any of the client repositories can is copied back up To the server to restore it. Every clone is really a full backup of all the data. Figure 1-3. Distributed version control.
Furthermore, many of these systems deal pretty well with have several remote repositories they can work with, so can Collaborate with different groups of people in different ways simultaneously within the same project. This allows-to-set up several types of workflows that aren ' t possible in centralized systems, such as hierarchical mod Els.