Skip to main content

SVN (Subversion) Tutorial

Subversion (SVN) is a version control system that allows you to manage changes to files and directories over time. This tutorial will guide you through the basics of using SVN.


1. Prerequisites

Before getting started with SVN, make sure you have the following installed:

  • SVN Client: Download and install an SVN client for your operating system. For example:
    • For Windows: TortoiseSVN
    • For macOS: Install via Homebrew with brew install svn
    • For Linux: Install via your package manager, e.g., sudo apt install subversion

Verify Installation

To check if SVN is installed correctly, run the following command:

svn --version

2. Setting Up an SVN Repository

Step 1: Create a Repository

To create a new SVN repository, use the following command:

svnadmin create /path/to/your/repository

Replace /path/to/your/repository with your desired repository path.

Step 2: Accessing the Repository

To access the newly created repository, navigate to its URL or path. If you're using a local repository, the path will be where you created it.


3. Importing Files into the Repository

You can import files or directories into your SVN repository using the following command:

svn import /path/to/your/files file:///path/to/your/repository -m "Initial import"

Replace /path/to/your/files with the path to your local files and /path/to/your/repository with the repository path.


4. Checking Out a Working Copy

To work with files in your SVN repository, you need to check out a working copy:

svn checkout file:///path/to/your/repository /path/to/your/working-copy

Replace /path/to/your/working-copy with the directory where you want to create your working copy.


5. Basic SVN Commands

Adding Files

To add a new file to your working copy and schedule it for addition to the repository:

svn add newfile.txt

Committing Changes

To commit your changes to the repository:

svn commit -m "Commit message describing changes"

Updating Your Working Copy

To update your working copy with changes from the repository:

svn update

Viewing Status

To check the status of your working copy:

svn status

Viewing Logs

To view the log of commits in the repository:

svn log

Reverting Changes

To revert changes in your working copy:

svn revert filename

6. Branching and Tagging

Creating a Branch

To create a branch in SVN, you typically create a copy of the trunk:

svn copy file:///path/to/your/repository/trunk file:///path/to/your/repository/branches/my-branch -m "Creating a new branch"

Creating a Tag

Similarly, you can create a tag:

svn copy file:///path/to/your/repository/trunk file:///path/to/your/repository/tags/my-tag -m "Creating a new tag"

7. Conclusion

SVN is a powerful version control system that helps manage changes to files and directories. This tutorial covered the basics of setting up and using SVN, including repository management, basic commands, and branching/tagging.

Further Reading

Content Review

The content in this repository has been reviewed by chevp. Chevp is dedicated to ensuring that the information provided is accurate, relevant, and up-to-date, helping users to learn and implement programming skills effectively.

About the Reviewer

For more insights and contributions, visit chevp's GitHub profile: chevp's GitHub Profile.