SVN and git are the mainstream version control systems. Here, we will record the similarities and differences between them.
1. In terms of architecture, SVN is centralized and git is distributed. The advantage of centralization is that the Code is highly unified, and the disadvantage is that it relies heavily on the central server. If the server is down or cannot be connected locally, you will not be able to submit updates, restore, compare, or collaborate. At the same time, the submission on SVN is not successful every time. If one person submits the submission before you submit the submission, it will prompt you to update the submission before submitting. In principle, SVN only focuses on the specific differences in file content, and records the files updated and updated each time. The distributed git will clone a local version library. When the network cannot be connected, it can still submit files and view historical version records. In git, each version library is equal. Unlike SVN, git only cares about whether the overall file data changes. Git does not store the different data before and after the file content, it is more like recording changed files as snapshots in a micro-File System (to improve performance, unchanged files will not be saved again ). 2. Differences between the version Library and the workspace SVN version Library and the workspace are separated. The directory detected locally in the workspace. It is a snapshot of the version library in a certain historical state. Each directory in the svn workspace contains a control directory named. SVN (Hidden directory ). The GIT version library is in the same directory as the workspace. the root directory of the workspace has a. Git subdirectory. Git's work zone must have. git Directory, which is used to store metadata and object databases, and there is only one git workspace. in addition, there is no control directory for the GIT directory. If you delete it, the entire history is broken and the version library is lost forever. (You can clone a version Library outside the workspace, and often push the commit to it to implement data backup .) Iii. SVN adopts the global version number and is continuous. Git calculates a hash value based on the file content or directory structure. It is a 40-character hexadecimal string and is globally unique. 4. SVN can be partially checked out, while git can only detect all. 5. SVN Updates can make the workspace and version library consistent. Git uses Git fetch (fetch to copy the remote database object to the local) and git pull (pull is equivalent to fetch + merge) to complete the remote update task. 6. Commit is a sub-directory of the branch SVN, which is essentially different from a common path. The GIT branch is only a file, so you can quickly switch between several branches in the same working directory. Git branches are completely isolated. The submission of SVN is a single clue, and there is only one commit chain. Git commit involves multiple clues, and there can be multiple commit links. In SVN, you cannot undo the submission, but can only modify it in subsequent submission. SVN has a feature that its information is never lost. Even if it is deleted, it can be found in earlier versions. The GIT code library belongs to an individual and can be modified at will. Git uses Git reset-hard to discard one or more of the latest commits. Conclusion: The SVN logic is clear, which is in line with the thinking habits of ordinary people. It is easy to manage and the centralized server can ensure security. The Code consistency is very high. It is suitable for projects with a small number of developers. The disadvantage is that the load on the server is too high, and the database capacity is increasing rapidly. If you cannot connect to the server, it will not work. Git is suitable for distributed development with emphasis on individuals. The pressure on public servers and data volume are not too large. It works offline. It is easy for any two developers to solve the problem. The disadvantage is that the learning cycle is long and the code confidentiality is poor.