Version control system-SVN

SVN

Apache Subversion, often abbreviated to SVN, is an open source version control system.

Official website: https://subversion.apache.org
Information: https://svnbook.red-bean.com, https://www.runoob.com/svn/svn-tutorial.html
Download: https://sourceforge.net/projects/win32svn/

Comparison with git

SVN (Subversion) and Git are both version control tools, and their functions are to help programmers manage and track code changes. Here are the main differences between the two:

  • Distributed and centralized
    Git is a distributed version control system where each developer has a complete code base. Developers can create, commit, and merge branches locally without needing to connect to a central server. This means that developers can continue working even if they are disconnected from the central server. In contrast, SVN is a centralized version control system where the code base is kept on a central server, and each developer gets the code from the central server and commits changes to the central server.

  • Branching and merging
    In Git, branching and merging are very easy and fast. Developers can easily create and merge branches, which makes parallel development and testing easy. In contrast, in SVN, branching and merging often require copying and merging folders, which can lead to conflicts and errors and requires a lot of manual work.

  • performance
    Git is generally faster than SVN, especially when performing operations such as commits and pulls. This is mainly because Git is distributed and can cache files locally, while SVN is centralized and requires a connection to a central server for operations.

Concept

  • Repository: The repository is where code and version history are stored in SVN. It is a server that centrally stores code.
  • Version (Revision): A version represents a specific state of the code warehouse, and each commit operation creates a new version. Each version has a unique identifier, usually represented by an increasing number.
  • Working Copy: A working copy is a local copy of the code taken from the SVN repository. Developers modify, add, and delete files in the working copy and synchronize these changes to the warehouse through commit operations.
  • Commit: Commit is the operation of applying changes in the working copy to the SVN repository. Commit creates a new version and records the changes in the working copy into that version.
  • Update: Update is the operation of updating the latest code in the warehouse to the working copy. An update operation compares the latest version in the repository with the working copy and merges the differences into the working copy.
  • Branch: Branching is the operation of dividing a code base into independent lines of development. By creating branches, you can develop, experiment, or fix in parallel without affecting the main code.
  • Merge: Merge is the operation of merging changes from one branch to another branch or trunk. Merging can bring together code changes on different branches, ensuring that all modifications are applied.

Tools

Client UI tools:

  • TortoiseSVN: A graphical interface tool suitable for Windows operating systems. It is integrated in the resource manager and can perform version control operations intuitively.
  • SmartSVN: A cross-platform SVN client tool that provides a visual interface and powerful functions and supports Windows, Mac and Linux operating systems.
  • Cornerstone: SVN client for Mac operating system, providing an intuitive user interface and easy-to-use version control functions.
  • RapidSVN: A cross-platform SVN client that provides a simple and easy-to-use interface and commonly used version control functions.

Web UI tools:

  • VisualSVN Server Manager: An SVN server management tool for Windows operating systems. It provides a web-based user interface that can manage SVN warehouses, permissions, users, etc.
  • RhodeCode: An open source SVN and Git version control system that provides a web interface to manage code repositories, user permissions, and team collaboration.
  • ViewVC: A Web-based SVN warehouse browsing tool that provides source code viewing, comparison, and retrieval functions.
  • WebSVN: A Web-based SVN repository browsing tool that provides a file browser-like interface to view code and history.

General process

  1. Create a repository: First, create a repository on the SVN server to store code and version history.

  1. Checkout: Perform a checkout on the local machine, copy the code in the warehouse to the local machine, and create a working copy. This working copy is the copy where you make modifications and operations locally.


    This is a typical SVN warehouse structure, in which the functions of each directory are as follows:

    branches: This directory is used to store branches of code. In software development, branches are often used for parallel development, experimentation, and repair work. Creating branches allows team members to develop on independent code lines to avoid disturbing the stable code on the trunk. Typically, each branch has its own folder and can be independently version controlled.

tags: This directory is used to store code tags. Tags are often used to mark project milestones, releases, or important release points. At a specific point in time, a snapshot copy of the code is marked as a label so that you can review and roll back to that version at any time. Tags are generally unmodifiable and are used to preserve historical records and implement version traceability.

trunk: This directory is used to store the main development code. Trunk is the core part of the project and contains the latest stable versions and features. Most development work takes place on trunk, where team members share and collaborate on code development. The code on the trunk is constantly updated and evolved over time.

Through this directory structure, SVN provides a way to organize code and version control. Directories for branches and tags help teams develop in parallel and manage important releases, while the trunk directory is the main code storage for the project. Such a structure facilitates team collaboration, version control, and code traceability.
  1. Modify files (Modify): Modify, add, and delete code in the working copy, and develop or repair according to needs.

  2. Update working copy (Update): When others submit new code to the warehouse, you need to perform an update operation to update the latest code in the warehouse to your working copy. This keeps your working copy in sync with the repository.

  3. Resolve Conflict: If you encounter a conflict during an update operation, that is, you and others have made incompatible changes to the same part of the code, you need to resolve the conflict. SVN will try to automatically merge the non-conflicting parts, but for the conflicting parts, you need to manually resolve them.

  4. Commit: After you complete the modification to the code, you need to perform a commit operation to apply your modifications to the warehouse. Commit creates a new version and records your changes into that version.

  5. Branch and Merge: If you need to do parallel development, experimentation, or fixes, you can create branches. Branches allow you to develop independently without affecting the main code. After you complete the work on the branch, you can merge the changes on the branch back to the trunk or other branches.

  6. View History: SVN records all version histories in the warehouse. You can check the modified content and author information of each version at any time.