Operations 11 min read

Master Essential SVN Commands for Linux: A Complete Cheat Sheet

This guide presents a thorough collection of Subversion (SVN) commands for Linux, covering checkout, add, commit, lock/unlock, update, status, delete, log, info, diff, merge, help, list, mkdir, revert, switch, resolve, cat, cleanup, import and related usage examples, helping users manage repositories efficiently.

ITPUB
ITPUB
ITPUB
Master Essential SVN Commands for Linux: A Complete Cheat Sheet

The article provides a comprehensive reference of common Subversion (SVN) commands on Linux, offering concise syntax, short aliases, and practical examples for each operation.

1. Checkout a directory

Retrieve a working copy from the repository: svn checkout path Example: svn checkout svn://192.168.1.1/pro/domain Short form:

svn co

2. Add new files

Add files to the repository: svn add file Examples: svn add test.php (add a single file) svn add *.php (add all PHP files in the current directory)

3. Commit changes

Submit modifications with a log message: svn commit -m "LogMessage" [-N] [--no-unlock] PATH Example: svn commit -m "add test file for my test" test.php Short form:

svn ci

4. Lock / Unlock

Lock a file: svn lock -m "LockMessage" [--force] PATH Example: svn lock -m "lock test file" test.php Unlock:

svn unlock PATH

5. Update to a specific revision

Update working copy: svn update -r REV path Without a path, the current directory and sub‑directories are updated to the latest revision.

Examples: svn update -r 200 test.php (restore file to revision 200) svn update test.php (synchronize with repository; if a conflict occurs, run svn update, resolve, then commit)

Short form:

svn up

6. Check status

Show file and directory status: svn status path Symbols:

? – not under version control

M – modified

C – conflict

A – scheduled for addition

K – locked

Verbose status: svn status -v path Short form:

svn st

7. Delete files

Delete a file from the repository with a log message: svn delete path -m "delete test file" Example:

svn delete svn://192.168.1.1/pro/domain/test.php -m "delete test file"

Or delete locally then commit:

svn delete test.php
svn commit -m "delete test file"

Short forms: svn del,

svn rm

8. View log

Show revision history for a path: svn log path Example:

svn log test.php

9. Show file info

Display detailed information about a file or URL: svn info path Example:

svn info test.php

10. Compare differences

Show local modifications compared to the base revision: svn diff path Example: svn diff test.php Compare two specific revisions: svn diff -r M:N path Example: svn diff -r 200:201 test.php Short form:

svn di

11. Merge revisions

Apply differences between two revisions to the working copy: svn merge -r M:N path Example (may produce conflicts that need resolution):

svn merge -r 200:205 test.php

12. Help

Show general help or command‑specific help:

svn help
svn help ci

13. List repository contents

List files and directories under a repository path: svn list path Short form:

svn ls

14. Create a new directory under version control

Make a new directory: svn mkdir PATH… (local) or svn mkdir URL… (immediate commit)

15. Revert local changes

Discard local modifications and restore the pristine copy:

svn revert PATH…

16. Switch repository URL

Update the working copy to a different URL or relocate its metadata:

svn switch URL [PATH]
svn switch --relocate FROM TO [PATH…]

Example relocation:

svn switch --relocate http://59.41.99.254/mytt http://www.mysvn.com/mytt

17. Resolve conflicts

Remove conflict markers after manual resolution:

svn resolved PATH…

18. Output file or URL contents

Print the contents of a file at a specific revision: svn cat TARGET[@REV]… Example redirecting a previous revision to a file:

svn cat -r PREV filename > filename

19. Cleanup

Remove leftover log files and release locks in the working copy:

svn cleanup

20. Import an unversioned directory tree

Fastest way to add a local directory tree to the repository:

svn import mytree file:///usr/local/svn/newrepos/some/project

After import, run svn checkout to obtain a working copy.

Additional: Adding Email Notifications

Configure a post‑commit hook using the provided comm-email.pl script to send email notifications after each commit. Set the repository and revision variables, then invoke the script with the appropriate email addresses.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

command-lineVersion Controlrepository managementsvnSubversion
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.