How to use SVN (Subversion) with command line
In this document, I will introduce the most useful SVN commands based on my personal experience. If there are any important commands I missed, feel free to contact me — your suggestions might benefit all readers.
What is SVN?
SVN (Apache Subversion) is a centralized version control system that allows multiple users to collaborate on code or documents by keeping track of changes in a central repository. Unlike Git, which is distributed, SVN relies on a single central server to store all versions of files, and developers check out and commit changes directly to this server.
⭐️ Key Features:
- Centralized version control (all history is stored on the server)
- Supports branching and tagging
- Efficient for managing binary files and large codebases
- Simple and mature with strong enterprise adoption
Tools for SVN
For Windows’ users, you can try TortoiseSVN.
For AIINS’s students, you can use browser to access SVN server (for downloading).
Git Workflow (for comparison)
SVN (Subversion) shares some conceptual similarities with Git. This tutorial assumes that readers are already familiar with Git, GitHub, and GitLab. When you want to download a repository from GitHub, the common workflow looks like this:
-
Clone the repository to your local machine:
git clone {url}
-
Modify the code.
-
Add the modified files:
git add {modified-files}
-
Commit the changes:
git commit -m "comments"
-
Push the changes to GitHub:
git push
In summary, there are four key Git commands: clone
, add
, commit
, and push
.
Below is a comparison to equivalent SVN commands:
Git Command | SVN Equivalent |
---|---|
clone | checkout |
add | add (with differences) |
commit + push | commit |
SVN Commands
List Repository Contents
Before downloading anything, verify the contents of the repository:
svn list {url}
Download
There are two main ways to download an SVN repository:
- Checkout: This will create a working copy of the repositorys
svn checkout {url}
Tip: If the repo is large and you only want the top-level directory (without files), use --depth empty
:
svn checkout {url} --depth empty
- Export: Use this if you want to download files without the
.svn
metadata:
svn export {url}
Add New Files or Folders
If you create new files or folders locally, you need to add
them explicitly (unlike Git, which detects them automatically).
To add a folder named example
:
svn add example
To add multiple files:
svn add test1.txt test2.txt
Commit Changes
Unlike Git, SVN commit
both saves and uploads the changes to the server:
svn commit -m "message"
Try It Yourself (For AIINS student)
Follow these steps to test SVN usage:
1. List the repository
svn ls {url}
🖥️ Example Output:
IRB/
digitaltwins/
drone/
event/
immersive/
presentation/
proposal/
sensing/
svn_example/
thesis/
2. Checkout the svn_example
directory
svn checkout https://nmsl.cs.nthu.edu.tw/svn/nmsl/svn_example
🖥️ Example Output:
A svn_example/test1_depth1.txt
A svn_example/test2_depth1.txt
Checked out revision 219.
3. Create a new folder and file with your name
cd svn_example
mkdir {your_name}
touch ./{your_name}/{your_name}.txt
4. Modify an existing file
echo "{your_name}" >> ./test1_depth1.txt
5. Add your new folder and file
svn add {your_name}
🖥️ Example Output:
A your_name
A your_name/your_name.txt
6. Commit your changes
svn commit -m "test {your_name}"
🖥️ Example Output:
Adding your_name
Adding your_name/your_name.txt
Sending test1_depth1.txt
Transmitting file data ..done
Committing transaction...
Committed revision 220.
Thanks for my colleague, Tse-Hou Hung, teaching me how to use SVN. This content is also revise by ChatGPT.