The difference, advantages and disadvantages between git and svn

Insert image description here

The difference, advantages and disadvantages between git and svn

svn: There is only a single centrally managed server that saves revisions of all files, and people working together connect to this server through clients to remove the latest files or submit updates.

Centralized version control system:

The version library is stored in a centralized server, and when working, you use your own computer, so you must first obtain the latest version from the central server, then start working, and then upload your own work after finishing the work. Pushed to central server. The central server is like a library. If you want to modify a book, you must first borrow it from the library, then go home and modify it yourself. After modifying it, put it back into the library.

Features of SVN

  • Each repository has a unique URL (official address), and each user obtains code and data from this address;
  • To obtain code updates, you can only connect to this unique version library and synchronize to obtain the latest data;
  • Submissions must have a network connection (non-local repository);
  • Submission requires authorization. If there is no write permission, submission will fail;
  • Submissions may not always be successful. If someone else submits before you, it will prompt "The changes are based on an outdated version, update first and then submit"... and so on;
  • Conflict resolution is a competition of submission speed: those who are quick will submit first and will be fine; those who are slow will submit later and may encounter trouble with conflict resolution.

**Benefits:** Everyone can see to some extent what others in the project are working on. Administrators can also easily control the permissions of each developer.
shortcoming:

  • Must be online to work. If the network speed is slow, it may take 5 minutes to submit a 10M file, which is quite suffocating.
  • The central server is a single point of failure.
    If it is down for one hour, no one will be able to submit updates, restores, comparisons, etc. during this hour, and it will be impossible to work together. If the central server's disk fails and no backup is made or the backup is not timely enough, there is a risk of data loss. The worst case scenario is to completely lose all historical change records of the entire project, except for some snapshot data extracted by the client, but this is still a problem because you cannot guarantee that all the data has been extracted.

To put it simply , SVN in principle only cares about the specific differences in file content. Each time it is recorded which files are updated, and which lines and content are updated.

git: Each terminal is a warehouse. The client does not just extract the latest version of the file snapshot, but completely mirrors the original code warehouse. Each extraction operation is actually a complete backup of the code warehouse.

Distributed version control system :

First of all, there is no "central server" in the distributed version control system. Everyone's computer has a complete version library. In this way, when you work, you don't need to be connected to the Internet because the version library is on your own computer. . Since everyone has a complete version library on their computer, how can multiple people collaborate? For example, you change file A on your computer, and your colleague also changes file A on his computer. At this time, you only need to push your modifications to each other, and you can see each other's changes. edited.

Compared with centralized version control systems, distributed version control systems are much more secure because everyone has a complete version library on their computer. It doesn’t matter if one person’s computer is broken, you can just copy one from someone else. That's it. If there is a problem with the central server of a centralized version control system, everyone will be unable to work.

When actually using a distributed version control system, it is rare to push revisions to the repository between two computers, because you may not be in the same LAN and the two computers cannot access each other, or your colleague may not be able to access each other today. Sick, his computer didn't turn on at all. Therefore, distributed version control systems usually also have a computer that acts as a "central server", but the role of this server is only to facilitate "exchanging" everyone's modifications. Without it, everyone can still work, but it is inconvenient to exchange modifications. .

Git features :

  • The repository of each clone in Git is equal. You can clone any repository to create your own repository, and your repository can also be used as a source for others if you wish.

  • Every extraction operation of Git is actually a complete backup of the code repository.

  • Submission is completely done locally, no one needs to give you authorization, you are the master of your repository, and submission will always be successful.

  • Even changes based on the old version can be submitted successfully, and the commit will create a new branch based on the old version.

  • Git submissions will not be interrupted until you are completely satisfied with your work. PUSH to others or others PULL your repository, and the merge will occur.

    During the PULL and PUSH processes, conflicts that cannot be resolved automatically will prompt you to complete them manually.

  • Conflict resolution is no longer a commit competition like SVN, but merging and conflict resolution are performed when needed.

the difference:

  • Git is distributed, while SVN is not distributed but centralized

  • Git stores content as metadata, while SVN stores content as files.

    Because the git directory is a cloned version of the repository on your machine, it has everything on the central repository, such as tags, branches, version records, etc. Comparing the size of the .git directory with that of .svn, you will find that they are very different.

  • Git does not have a global version number, but SVN does

    By far this is the biggest feature that Git lacks compared to SVN.

  • The integrity of Git's content is better than that of SVN

    GIT's content storage uses the SHA-1 hash algorithm. This ensures the integrity of code content and reduces disruption to the repository in the event of disk failures and network problems.

  • Branches are different

Guess you like

Origin blog.csdn.net/weixin_44786330/article/details/127040984