Using SVN from the command-line

From ISoft Wiki
Jump to navigationJump to search

This document explains the three most important SVN commands that you can use from a command line. It doesn't deal with questions you may have about how to use TortoiseSVN, ISoft's favorite SVN tool for Windows.

Although SVN is a command-line program, it is also context-sensitive. In other words, SVN assumes that you want to operate on files in the current directory, so you should change directories to your "working copy" before getting started.

You run SVN commands by typing 'svn', followed by the command, followed by the command arguments.

Checkout

Before you can use or work on a product that is stored in SVN, you need to check it out. First, you need an SVN username and password, and you need to know the URL of the files you are checking out. (For example, ITrack products are kept in https://svn.isoftdata.com/ITrack/trunk, LXE is kept in https://svn.isoftdata.com/Web/trunk/EnterpriseLX, etc.

Then, create a folder for your local "working copy" of the product, go to the folder, and enter 'svn checkout' followed by the URL, like this:

svn checkout https://svn.isoftdata.com/Web/trunk/EnterpriseLX

This command will check out all the files needed for running LXE on a given server. (Note that LXE is not ready to use out-of-the-box like this; in order to prepare LXE for actual use follow the steps for Installing LX.)

Update

If you have already checked out files in the past, and you want to update those files based on what is in the SVN repository, you use the 'update' command, like this:

svn update

If there are conflicts between files, you may need to choose between the version of the file that is in the repository ("tc") and the version of the file that is stored in the current directory ("mc"). Otherwise, you may wish to hand-carve the local file based on the differences between it and the one in the repository ("ec"). If you just want to see the differences, type "df" at the question prompt. (For details on the 'diff' command, including how to read its output, enter 'man diff' from a linux prompt.)

If you're changing things in production, before making any commits, please run the following to see local changes from your last checkout.

svn stat

The command to see differences between your local copy and what's currently on svn is as follows:

svn stat -u

Please check both of these things before committing to production.

Commit

You may wish to upload local changes to the repository, creating a new revision that reflects those changes. To do so, you must first ensure that the local copy has been updated (see UPDATE above). Then, commit your changes like this:

svn commit

SVN may ask you to enter some comments in a text editor regarding your changes; you can enter comments or just type :wq to submit your changes without comment.

Conclusion

These are the three day-to-day operations you will likely want to use from the command line. For more detailed information about using SVN, you may wish to read Version Control with Subversion.