The difference between GIT and SVN


GITIt’s distributed,SVNNo

This isGITAnd other non distributed version control systems, such asSVNCVSWait, the core difference
GITFollowSVNIt also has its own centralized version library or server. However,GITIt is more likely to be used in distributed mode, that is, each developer will clone his own version library on his own machine after checking out the code from the central version library / server.
Because every developer has one on their computerLocal Repository, so even without a networkCommit, view the historical version records, create project branches and other operations, and then push the network to the server again.

GITStore content as metadata, andSVNAccording to documents

Because.GITDirectory is a clone version library on your machine. It has everything on the central version library, such as tags, branches, version records, etc. .GITThe volume size of the catalog followsSVNBy comparison, you will find that there is a big gap between them.

GITThe version number is unique in the world, andSVNVersion number is globally unique

GITFor each submission, a SHA-1 hash value is calculated based on the content of the file or the structure of the directory to get a 40 bit hex string,GITUse this string as the version number.
SVNAndGITVersion number comparison

  • All saved inGITAll data in the database is indexed by this 40 bit hash value, not by the filename.

  • The advantage of using hash as version number is that for a distributed version control system, the version number generated by each person after each submission will not be repeated. Another advantage is to ensure the integrity of the data, because the hash value is calculated according to the content or directory structure, so we can also judge whether the data content has been tampered.

  • SVNThe version number of is continuous, and the next version number can be predictedGITThe version number of is not.
    Because subversion is centralized version control, it is easy to achieve version number continuity.GITIs a distributed version control system, andGITThe hash value of 40 bits is used as the version number, and each person’s submission is completed independently without priority (even if the submission has priority, it is also different due to the direction and timing of push / pull).GITAlthough the version number of is not continuous, there is a clue, that is, each version has a corresponding parent version (one or two), which can form a complex submission chain

  • GITVersion number simplification for:GITYou can use a string of any length starting from the left as the simplified version number, as long as the simplified version number is not ambiguous. Generally, 7-digit short version number is used (you can use a shorter version number as long as there is no duplicate).

In use, it is found that every time the entire directory is submitted,SVNIt is to mark the version number of all documents with or without update, andGITAt first, I felt thatSVNNoGITIt’s reasonable. It’s a waste to type the version number of a file that hasn’t been updated, but combined withSVNIts own characteristics,SVNEach version of is a complete warehouse. According to some god, it has a high fault tolerance rate

GITBranches are different from SVN branches

Branch inSVNThis is not special. It is another directory in the version library. If you want to know whether a branch has been merged, you need to manually run a command like SVN propget SVN: mergeinfo to confirm whether the code has been merged. Therefore, some branches are often missed.
However, handlingGITThe branch of is quite simple and interesting. You can quickly switch between several branches from the same working directory. It’s easy to find out the unmerged branches. You can merge these files easily and quickly. becausegitBranches are managed based on differences with minimal cost
I only experienced it in practicegitIt’s really easy to switch with the command line and it’s easy to be prompted to know which branch hasn’t been merged

SVNMust firstUpdateCanCommit

Forget that there will be some errors when merging,gitThis is still relatively rare.
In actual use,gitA friendly point is that when there is a conflict, it will prompt to resolve it,SVNIt’s a direct update, and then there’s a bunch of conflicts

SVNBetter security control and authority management.

gitNext, if a person after clone, all the code and history are leaked. andSVNHave detailed permission control according to directory level

GUI tools, orSVNStronger

cloneDifferences between new warehouses

Clone a new directory with five branches,SVNCopy 5 versions of the file at the same time, that is, repeat the same action five times. andgitJust get the elements of each version of the file, and then load only the main branch (Master), which determinesgitSpeed ratioSVNfast

gitContent integrity is better thanSVN

gitThe content store of uses SHA-1 hash algorithm. This ensures the integrity of the code content,Ensure that the damage to the version library is reduced in the event of disk failure and network problems.

Differences in handling conflicts

gitYou will be prompted to resolve the conflict before submitting it. My general way to resolve the conflict is to use local resources firstgit stashSave it, pull down the changes on the server, and thengit stash pop, resolve conflicts manually and resubmit them, andSVNWhen you know there is a conflict, the local file is already a conflict file,SVNThe conflict file and folder will be identified with exclamation mark, and three files will appear locally
Among them:
.mineThe version you are going to submit after modification;
.r3368Is your initial version;
.r3439It’s the version that someone else submitted before you
Find conflicting files right click to findEdit conflictsModify the conflict, save after adjustment, right-click to selectResolved… to resolve the conflict

Reference material

What’s the difference between SVN and git
Five basic differences between GIT and SVN