GITAnd other non distributed version control systems, such as
CVSWait, the core difference
SVNIt 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 computer
Local Repository, so even without a network
Commit, view the historical version records, create project branches and other operations, and then push the network to the server again.
GITStore content as metadata, and
SVNAccording to documents
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 follows
SVNBy comparison, you will find that there is a big gap between them.
GITThe version number is unique in the world, and
SVNVersion 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.
GITVersion number comparison
All saved in
GITAll 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 predicted
GITThe 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, and
GITThe 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, and
GITAt first, I felt that
GITIt’s reasonable. It’s a waste to type the version number of a file that hasn’t been updated, but combined with
SVNIts 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
SVNThis 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.
GITThe 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. because
gitBranches are managed based on differences with minimal cost
I only experienced it in practice
gitIt’s really easy to switch with the command line and it’s easy to be prompted to know which branch hasn’t been merged
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. and
SVNHave detailed permission control according to directory level
GUI tools, or
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. and
gitJust get the elements of each version of the file, and then load only the main branch (Master), which determines
gitContent integrity is better than
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 first
git stashSave it, pull down the changes on the server, and then
git stash pop, resolve conflicts manually and resubmit them, and
SVNWhen 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
.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 find
Edit conflictsModify the conflict, save after adjustment, right-click to select
Resolved… to resolve the conflict
What’s the difference between SVN and git
Five basic differences between GIT and SVN