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.
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 co2. 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 ci4. Lock / Unlock
Lock a file: svn lock -m "LockMessage" [--force] PATH Example: svn lock -m "lock test file" test.php Unlock:
svn unlock PATH5. 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 up6. 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 st7. 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 rm8. View log
Show revision history for a path: svn log path Example:
svn log test.php9. Show file info
Display detailed information about a file or URL: svn info path Example:
svn info test.php10. 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 di11. 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.php12. Help
Show general help or command‑specific help:
svn help svn help ci13. List repository contents
List files and directories under a repository path: svn list path Short form:
svn ls14. 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/mytt17. 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 > filename19. Cleanup
Remove leftover log files and release locks in the working copy:
svn cleanup20. 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/projectAfter 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
