Table of contents
1.
Introduction
2.
Installation of SVN Client
2.1.
Note: If you're unfamiliar with Subversion, a graphical client might be a better option. We do not keep a list of such clients; instead, we search for Subversion GUI clients on the Internet.
3.
Vocabulary
3.1.
What is a Repository?
3.2.
What is a working copy?
4.
Task
4.1.
Data importing into the repository
4.2.
Checking out a working copy
4.3.
Updating a working copy
4.4.
Making changes in your local working copy
4.5.
Performing file and directory operations
4.6.
Branching and tagging
5.
Setting a local Repository.
5.1.
On Unix
5.2.
On windows
6.
Frequently asked questions
6.1.
What do you mean by SVN?
6.2.
In SVN, how do you resolve conflicts?
6.3.
What is the command for creating a new version-controlled directory?
6.4.
What are the most commonly used subversion commands?
6.5.
What is the procedure for importing your existing directory into the new repository?
7.
Conclusion
Last Updated: Mar 27, 2024

Apache Subversion Guide

Author Riya Bhogra
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

If your job requires you to handle frequently updated papers, web pages, and other data types, you should consider using a version control system if you haven't already.

This, among other things, allows you (and a group of possible collaborators) to track changes to a file and roll back to a previous version if an issue arises or an update fails to deliver the desired results.

Apache Subversion is the most extensively used version control system in the free software environment (or SVN for short). You can use HTTP and a web server to access a Subversion repository with the help of mod dav svn (Apache's Subversion module).

Installation of SVN Client

Install the svn client to begin working together on a project that uses Subversion as its version control system.

You can create the client software from source code or download a binary package to install it. The official binary packages page lists locations where you can get a pre-built Subversion client. Download the source code from the Source Code page if you want to compile the software yourself.

You should be able to test the client right after installing it by using the svn command. The following output should appear:

$ svn

 

Type 'svn help' for usage.

You can now interact with the remote repository via the command-line client.

Note: If you're unfamiliar with Subversion, a graphical client might be a better option. We do not keep a list of such clients; instead, we search for Subversion GUI clients on the Internet.

Vocabulary

What is a Repository?

The repository is a version control database generally hosted on a server and is accessible via an Apache HTTP Server (mod dav svn module) or a svnserve server. The repository serves as a single source of truth and a central storage location for the versioned data's whole history of modifications in the form of revisions.

Examples of repository URLs:

  • Apache HTTP Server: https://svn.example.com/repos/MyRepo/MyProject/trunk
  • svnserve: svn://svn.example.com/repos/MyRepo/MyProject/branches/MyBranch
  • Direct access (Unix-style): file:///var/svn/repos/MyRepo/MyProject/tags/1.1.0
  • Direct access (Windows-style): file:///C:/Repositories/MyRepo/trunk/MyProject

What is a working copy?

The working copy is your personal, local workspace for interacting with the central Subversion repository. You utilize the working copy to make changes to your project's content and to retrieve modifications made by others.

The working copy holds your project's data and appears and behaves similarly to a regular directory on your local file system, with one key exception: the working copy keeps track of the status and modifications of the files and directories it includes. The working copy is similar to a conventional directory with version control capabilities. At the base of a working copy is an administrative directory called.svn. The administrative directory holds the metadata that Subversion needs to manage its version-control capabilities.

Task

Data importing into the repository

The svn import command should be used to import existing non-versioned material into an SVN repository. Here's an illustration:

$ svn import https://svn.example.com/repos/MyRepo/MyProject/trunk -m "Initial project import"

Checking out a working copy

It would be best if you first built a local duplicate of the versioned project before you can begin making changes to its data. You can use the svn client from the command line or any GUI-based client. The svn checkout command is used to create a working copy of the project on your machine. Here's an illustration:

svn checkout https://svn.example.com/repos/MyRepo/MyProject/trunk MyWorkingCopy

 

As a result, you'll have a functioning copy of the trunk of the MyProject project, which is stored in the MyRepo repository. On your computer, the working copy will be under the MyWorkingCopy directory.

Updating a working copy

You should perform the svn update command on your working copy to stay up to date and get the changes made by others. As a result, your working copy will sync with the repository and download your coworkers' updates.

Before committing local changes to the repository, it's a good idea to update your working copy.

Making changes in your local working copy

Most of the time, you'll make changes to the project's data by changing the contents of the working copy. You're ready to commit the changes to the central repository whenever you're satisfied with them and have thoroughly evaluated them.

  • Modifying existing files

 

Modify the files as needed with your preferred text processor, graphics editor, audio editing software, IDE, etc. Subversion will immediately recognize the modifications as soon as you save them to disk.

  • Committing your changes to the repository

 

You should use the svn commit command to publish the modifications you made in your working copy.

 Here's an illustration:

$ svn commit -m "My Descriptive Log Message."

Performing file and directory operations

Within the working copy, you can do whatever you want with your project's data, but operations like copying, moving, renaming, and deleting must be done with the appropriate svn commands.

  • Adding new files and directories

 

Subversion will see new files or directories as "unversioned" if they are added to the working copy. Unless you use the svn add command, it will not immediately start tracking the new files:

$ svn add foo.cs

 

  • Moving and renaming files and directories

 

Using the svn move or svn rename commands, you can move and rename files and directories: 

$ svn move foo.cs bar.cs

 

The command svn rename is an alias for the svn move.
 

  • Copying files and directories

 

Using the svn copy command, copy files and directories:

$ svn copy foo.cs bar.cs

 

  • Deleting files and directories

 

Using the svn delete command, remove files and directories.

$ svn delete foo.cs

 

  • Reverting or discarding local changes

 

Using the svn revert command, you can discard your uncommitted local changes:

$ svn revert foo.cs

Branching and tagging

To generate branches and tags, you should use the svn copy command. This is the same command that you use to copy things from your working copy to the repository when you want them to be related historically.

Creating a branch using direct URL to URL copy

Subversion makes branching a breeze. In its most basic form, creating a new branch entails running a command against the URLs of a remote repository. Let's make a new branch from the mainline trunk, for example:

$ svn copy https://example.com/MyRepo/trunk https://example.com/MyRepo/branches/MyNewBranch -m "Creating a new branch"

Setting a local Repository.

You can construct a Subversion repository on your computer and interact with it locally using the file:/ method. This method tracks personal files and single-person projects using Subversion locally.

The approach below builds a virtual environment for a project that already exists. It creates a functioning clone of a newly generated local Subversion repository from a directory containing a project. As a result, you can make changes to the files in the working copy while keeping track of them in your local repository.

On Unix

  1. Make a parent directory for your project. svnrepos is the location where you'll store your SVN repositories:
$ mkdir -p $HOME/.svnrepos/

 

2. Make a new repository called MyRepo in the folder. Svnrepos:

$ svnadmin create ~/.svnrepos/MyRepo

 

3. In the new repository, create a recommended project layout:

$ svn mkdir -m "Create directory structure." \
  file://$HOME/.svnrepos/MyRepo/trunk \
  file://$HOME/.svnrepos/MyRepo/branches \
  file://$HOME/.svnrepos/MyRepo/tags

 

4. Change to the./MyProject directory, which contains your unversioned project:

$ cd $HOME/MyProject

 

5.Make a working clone of trunk/ in the repository in the current directory:

$ svn checkout file://$HOME/.svnrepos/MyRepo/trunk ./

 

6.Schedule the upload of your project's files to the repository:

$ svn add --force ./

 

7. Files for the project should be committed:

$ svn commit -m "Initial import."


On windows

  1. Create a parent directory called C:Repositories for your SVN repositories:
mkdir C:\Repositories

 

2. Make a new repository called MyRepo in the C: drive. Repositories:

svnadmin create C:\Repositories\MyRepo

 

3. In the new repository, create a recommended project layout:

svn mkdir -m "Create directory structure." ^
  file:///C:/Repositories/MyRepo/trunk ^
  file:///C:/Repositories/MyRepo/branches ^
  file:///C:/Repositories/MyRepo/tags

 

4. Change to C:MyProject, the location of your unversioned project:

cd C:\MyProject

 

5. Make a working clone of trunk/ in the repository in the current directory:

svn checkout file:///C:/Repositories/MyRepo/trunk .

 

6. Schedule the upload of your project's files to the repository:

svn add --force ./

 

7. Files for the project should be committed:

svn commit -m "Initial import."

 

8. Make the following changes to your working copy:

svn update

Frequently asked questions

What do you mean by SVN?

Subversion is a form of a version control system, and SVN stands for it. Although version control is a significant issue, the following are some of the benefits of SVN.

  • Track changes to your code base (i.e., who made what modifications) and revert to earlier revisions.
  • Collaborate with your coworkers by having the version control system integrate your modifications with other developers' updates on the same file (s)
  • Create code branches to allow you to work on many versions of your project at the same time.

In SVN, how do you resolve conflicts?

One of three actions can be done to resolve a conflict: Hand-merge the contradictory text (by examining and editing the conflict markers within the file). Overwrite the working file with one of the temporary files. To undo all of the local modifications, run svn reverse FILENAME.

What is the command for creating a new version-controlled directory?

The following commands can be used to create a new version-controlled directory:

svn mkdir directory
svn mkdir http://url/directory

What are the most commonly used subversion commands?

The following are some examples of subversion commands.

  • Import
  • Checkout
  • Commit
  • Update

What is the procedure for importing your existing directory into the new repository?

You'll need to write a command to import your existing directory into the new repository.

svn import/home/mysurface/programming file:///home/mysurface/repo/programing_repo-m “initial import”

Conclusion

In this article, we have extensively discussed Apache Subversion Guide with its installation, vocabulary, configuration, and basic tasks. We hope this blog has helped you enhance your knowledge regarding the same. 

Recommended Readings:

 

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problems, interview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Live masterclass