What is? git?

A Distributed Revision Control System

A distributed version control system

The commonly used version control systems are GIT,SVN

What's the difference between them ?

Let's start with their advantages and disadvantages


advantage :

Distributed , Everyone involved in the development has a complete repository on their computers , There's no need to worry about hard disk problems . Each clone (clone) Is equal . You can create your own version library from a clone of any version library , At the same time, your repository can also be used as a source for others .
* Git Every extraction operation of , It's actually a full backup of the code repository .
* Without networking , It can also be submitted to the local warehouse , You can view all of the past log, After the net push It can be operated remotely . And there's no need for authorization , Submission will always succeed .
* Provides very powerful branch management capabilities
Git Is better than SVN---- reason :Git Using the SHA-1 Hash algorithm , It can ensure the integrity of the code content , Make sure to reduce the damage to the version Library in case of disk failure and network problems
shortcoming :

* Authority management is not convenient , Generally, the system can set the file read and write permissions to do the permission control . Plug in required gitolite, Configuration trouble , Or directly gitlab Administration
* The working directory can only be the entire project . such as checkout, Set up branches , It's all based on the whole project . and svn It can be based on a directory in the project


advantage :

* Better authority management function , You can precisely control the permissions of each directory
* Using relative git Let's be simple

* Centralized , If there is a problem with the central server , No one can work , It's also troublesome to reply , because SVN The difference between each change is recorded , It's not a complete document
* There is no branching function git powerful
* No speed git fast , If there are five branches , It will copy all the files in five branches
* You have to be connected commit

Main differences

* Git Care about whether the overall file data changes , and SVN This kind of version control system is basically concerned with the specific differences of file contents
. This kind of system records which files are updated every time , however Git The difference data of these changes before and after are not saved .Git It's more like taking a snapshot of the changed files , It's recorded in a tiny file system . Every time an update is submitted , Will look through all the information of the file and take a snapshot of the file , Then save an index to the snapshot . In order to improve performance , If the file does not change ,Git It will not be saved again , Only make a link to the last saved snapshot .
      I think ,Git There is no image SVN Whether the updated details will be analyzed and submitted for each submission , It's very scientific , because Most of the time, we don't have to check        
What updates have been made to each file , because git The complete historical version library will be saved locally , Another user development will have ten libraries , There will be a lot of redundancy    
   data . But in the SVN This is scientific , The server keeps a unique historical version library , Contains all the details , You can check on one when you need it      
Update and change information of documents and previous versions . and Git The snapshot of the previous day and the current file will be taken for a difference operation , The updated information is displayed

* Git Most operations in require only local file access , You don't need to connect to the Internet to see all the historical versions , and SVN Need networking
. If you want to see the difference between the current version and the historical version ,git Will take a month ago snapshot and the current file to do a difference operation
* SVN Disconnect or disconnect from the network VPN You can't commit code , however Git Yes, first commit To local warehouse
. use SVN The words of , Disconnect or disconnect VPN Time , unable commit code , Not for a long time commit The code loses a lot of development history , It's like using word Code words don't work ctrl+s Keep the same danger .Git Updates can be submitted frequently at any time , Local warehouse commit It takes little time .
* Git Content integrity is better than SVN. because Git  stay commit( Store locally ) perhaps push( Upload to remote warehouse ) before , By calculating the structure of a file's content or directory
SHA-1 Hash value , As a fingerprint string for content verification , This result is used as the unique identification and index of the data , Received in the remote warehouse commit After the file of , The hash value is calculated again and compared with the hash value passed in , If not , The description file becomes incomplete at the time of transmission , Or the file data is damaged due to disk damage . In addition, in the
Git Everything in the database is indexed with this hash value , Not by the file name . 
* Git Cloning a complete project is fast ,SVN Very slow
. Let's talk about cloning a complete project with five branches and a repository ,SVN Is it copied at the same time 5 Versions of files , That is to say, repeat the same action five times . and Git
Just get the elements of each version of the file , Then only the main branches are loaded (master)
* Git Branching ratio SVN powerful .
branch (Branch)

SVN: A branch is a complete directory , And this directory has the complete actual file . If the worker wants to open a new branch , It's going to affect everyone , Everyone will have the same branch . If your branch is testing system modules for security checks , Change a branch , Others will have to branch out and download again , It will also be destructive to the stable version .

Git: Each working member can open unlimited branches in its own local version library . give an example : When I try to break my program ( Security testing ), And want to keep these modified files for future use ,
I can open a branch , Do what I love . There's no need to worry about getting in the way of other members of the staff . As long as it is not merged and committed to the main repository , No one member of the staff will be affected . When I don't need this branch ,
I just need to remove it from my local repository .

Creation time of branch in development

If a new website is developed , Already in main branch (master) Developed on 1.0 Release version , How to develop a new function module , We need to create a branch (dev), Instead of continuing development in the main branch .

reason :

When developing new modules , You may encounter a variety of bug Or conflict , If still in the main branch development , If the conflict is serious , It affects the current stable version , It will add a lot of trouble . If you develop on a new branch , When the conflict is serious , Delete the current branch , A new branch . And the branch can also retain the various kinds of things that may appear in the development bug The convenient repair list does not affect the use of multiple main branches .
If we ask for two ring branches . If you switch to master When branching , The current is saved dev The state of the branch , In order to facilitate future development , Prevent lost development schedule . such as , In progress dev Develop new modules , then 1.0 There is a serious problem bug, Switch back to the main branch first , Then create an emergency repair for the main branch repair branch , Fix the problem in it . After passing the test , Back to the main branch , take repair Branch merging , then push To remote warehouse . Switch back to develop the new module dev branch , Continue development from the previous exit progress .
Git Branches can be opened at any one of the commit points , It can be said that it is very convenient !

 Git There are three states :

* Submitted (committed) Indicates that the data has been safely stored in the local database .
* Modified (modified) Indicates that the file has been modified , But it hasn't been saved to the database .
* Staged (staged) Indicates that the current version of a modified file is marked , Include it in the next committed snapshot .
Git The concept of the three work areas of the project :

* Git Warehouse :Git A place to store metadata and object databases for a project . This is Git The most important part of , When cloning a warehouse from another computer , This is the data copied here .
* working directory : It is the content extracted independently from a certain version of the project . These are from Git Files extracted from the compressed database of the warehouse , Put on disk for you to use or modify .
* staging area : It's a document , Saved the file list information to be submitted next time , In general, the Git In the warehouse directory . Sometimes called “ Indexes ”, But generally speaking, it is called temporary storage area .
Basic Git The workflow is as follows :

* Modify files in working directory .
* Temporary file , Put a snapshot of the file into the staging area .
* Submit update , Find files in staging area , Permanently store snapshot to Git Warehouse directory .
General development process

* Create warehouse (web end Remote establish ) Clone from remote warehouse to local
* Create and switch to property branch
* establish / Modifying documents
* Submit workspace files to staging
* Submit staging file to local warehouse
* Merge trunk branch code
* Push local warehouse to remote warehouse
I'll introduce you to the next one git Basic usage of , It's good to master the above concepts


©2019-2020 Toolsou All rights reserved,
Send love - A little romance for programmers VHDL—— Design of frequency divider Python Implementation of Hanoi Tower code It's over , Starting salary 30khtml+css+js Make a simple website home page QQ Login interface implementation Hill sorting of sorting algorithm ——c++ realization 【 Wechat applet learning 】 Netease music cloud code page implementation details Resume the 13th session python Blue Bridge Cup 2022 Solution to the 13th Blue Bridge Cup ( whole )