SVN Command Line Basics

- by

I keep forgetting SubVersion basics from the command line, and thought this quick little cheat sheet might come in handy. I’ll cover the basics:

  • checking out
  • updating your local copy
  • checking current file status
  • committing a change
  • adding a file
  • removing a file

Checkout Out

To make an initial copy of an online repository, we use the checkout command. It’ll create a new folder with the name of the online repo in the current directory and copy all its contents into it. Checkout can be abbreviated with co:

svn checkout your-url
svn co your-url

Updating your Local Copy

If you’ve already checkout out a repository, and you’re not sure if changes have been made on the remote, you can update your local copy using the update command. It can be abbreviated with up:

svn update

A list of updated files will be displayed, as well as the revision of the current commit. If no files are displayed, your local copy is up to date. Check svn help update for details.

Checking the status of current files

SVN let’s you display a status of all current files. This lets us decide what has been changed locally before a commit has been made. We use the status command for this, or its abbreviation stat:

svn status

A list of files and their status appears, or nothing if all files in your local copy match the online repository. Check svn help status for details.

Committing a change

When one or more files have been changed, it’s time to submit this change to the online repository. We do that with the commit command, abbreviated with ci (short for checkin). It’s customary to leave a small comment as to what this change does, using the -m switch:

svn commit -m "Super awesome change"

Commit will store changes across multiple files. There’s no need to submit each file individually. The commit command is designed to make all changes final, such as updates, additions and deletions. It’s usually used at the end of all changes that have been make, as a final synchronisation step.

Adding a file

Add will add a new file to the repository. It’s necessary to add files to put them under version control, otherwise they’ll be designated with the ? parameter (as unknown state). The same goes for directories.

svn add yourfile
svn add yourdirectory

Removing a file

If you delete a file from the local directory, we must tell SVN about it. Otherwise it will assume the file still in the online repo is out of sync and should be downloaded to your local copy first (being obviously missing and all). Delete will remove a file for us. The command can be abbreviated with del, remove or rm:

svn delete yourfile
svn delete yourdirectory

Further Reading



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.