How to Guide Subversion

From GT RoboJackets

Jump to: navigation, search

Subversion is the version control system used by RoboJackets.

Contents

Interfaces

Subversion

Subversion works on a client-server model. More specifically the server acts as the master repository of code and the client checks out a copy of this code into a working copy. When you are editing the code, you are editing your own working copy. To allow everyone else to see your code changes, you must commit the code to the repository. Every time a commit occurs, the revision number of the code in the repository increments.

Commands

These are common commands that will get you started. There are more but you can discover those on your own.

checkout

This will be the first command you run before you start to work on a project for the first time. It will ask the server for a list of files at a certain location and then download those files to your computer. These files then become the working copy that you can edit.

The commands are all shown from the command-line. There are graphical tools available but a good command-line understanding will help in using the graphical tools.

Usage:

$prompt: svn checkout <remote-path> <local-path>
$prompt: svn co <remote-path> <local-path> [shorthand version]
  • The remote path is the location of a directory on a Subversion server that has the files you want to check out (recursively). This will usually be given to you by the project lead or maintainer.
  • The local path is the location to store the files. This can be of your choice, but remember that Subversion will drop all the files in the remote-path into the local-path so it is best to have a separate folder for the files.
  • Note: svn will create the folder if it does not exist and you have permission to do so.

commit

This command will update the repository copy with the changes you have made to the working copy. It will also ask you for a comment on the changes that are being committed so others can know what was altered for the revision change.

Usage:

  1. change to the directory containing the working copy. Not just the directory with the folder you placed the files into, but actually into that folder.
  2. $prompt: svn commit

That's it! Subversion will bring up a file telling you about the changes as well as asking you to type a comment. Edit the file, save the changes, and close it. Subversion will then transfer all the appropriate files over to the server. Anyone that does a checkout from the server now will also get your changes.

status

The status command will list the working copy changes that have not been committed to the repository. This will include all modified files (M), deleted (D), added (A), unknown (?) or other status indicators. The purpose of the svn status command is to let know know which files Subversion considers to be in the working copy. This becomes important as you add and remove files from the working copy.

Usage:

  1. change to the working copy directory.
  2. $prompt: svn status

It will print out the status to the console, similar to:

? .cdtproject
? .project
? bin
? .settings
M Makefile

The (?) signify that subversion does not know about those files and that they are not under version control. The (M) signals that the file has been modified but no commit has been performed to upload the changes to the repository

update

The update command is an important command to run from time to time and especially when sitting down to begin work on an already checked out working copy.

It will ask the repository for a list of files/changes that have occurred since your last checkout or update. It will then download the files and perform the changes. Once the command runs, you will have the latest revision off the repository.

Usage:

  1. change to the working copy directory
  2. $prompt: svn update

Subversion will then print out a list of the updated files and you can continue to work.

  • Note: it is a good idea to always run svn update before you start to work as well as right before you do an svn commit. This will ensure that you start working on the latest files and also have any changes that might have occurred on the file you were editing while you were editing it. This practice will help avoid conflicts and painful code resolutions.

add

The add command will become important as you find the need to expand the project beyond the files you got from the repository. It will tell subversion that you want a certain file or directory put under version control.

Usage:

  1. change to the working copy directory
  2. $prompt: svn add <path>

This will tell subversion to mark the <path> for version control. More than one file can be added and the command can be run multiple times for different files.

  • Note: Remember that this operation is local and for the file(s)/directory to actually be added to the repository you must do an svn commit on the working copy.

delete

Inevitably you will need to delete files. They may be outdated or newer version with different names have been created. If the file/directory is not under version control (? next to it in svn status) then you can just use your Operating Systems delete methods. If the file/directory is under version control you must tell subversion that you want to delete it.

Usage:

  1. change to the working copy directory
  2. $prompt: svn delete <path>

This will tell subversion to remove the <path> from version control as well as removes the file locally from the filesystem.

  • Note: Once again this change is local. Running svn status will show a (D) next to the removed files. Only after you run svn commit will the files be removed from the server repository. And don't worry! This is version control, if you mess up, you can go back!

import

This command is rarely used. It is used to bring in files into a repository for the first time. Most likely your project lead or maintainer will do this action and all you have to do is svn checkout on the path they give you. Nevertheless, the command is not hard to use; it is similar to the checkout command but in reverse (local -> remote).

Import is performed on regular files or directories on the filesystem, NOT ones already under version control. It will take the files and move them into the repository for checkout by all those with permission.

Usage:

  1. find a directory or list of files that you wish to import into the repository
  2. $prompt: svn import <local-path> <remote-path>

Subversion will take all the files at local-path (can point to a directory) and import those files/directories (recursively) into the <remote-path> which it will create if it does not exist and you have permission to do so.

  • Note: svn import only uploads the files to the repository, it DOES NOT make a working copy. It is up to you to delete the uploaded files (they are no longer needed becausethey are now on the server) and then perform an svn checkout on the remote-path to fetch the files and create a working copy of them locally so you can start to edit them.

Tools

Windows subversion client: http://tortoisesvn.tigris.org/

Personal tools