Posts Tagged ‘version control’

SVN CRIB SHEET

// December 16th, 2008 // No Comments » // SVN

Subversion – A method of version control. Keeps a copy of all changes made to files commited and stored to the repository. A time and frustration saving tool that requires a bit of patience to understand it.

SVN diagram

SVN diagram

Basic Tools to use an existing repository

svn st    # Show status of files in current location in relation to the repository

svn up    # Update files in current location with most recent versions

svn ci    # Commit changes made to repository

svn add   # Add file to Repository (Files must then be commited)

svn del   # Delete file from repository

svn log   # Shows Log File for Current Location

svn co file:///path/to/repository/directory/ namedfolder # Checks out contents of the repository folder specified to namedfolder

Where the repository lives

The root directory (“/usr/local/svn/Repository” for example) is the main repository for SVN, then Each Sub project has it’s own directory. Within each Sub Project there is a three folder structure

trunk

the current LIVE version of the site – this is where ALL changes happen

tag

Versions of the site are tagged and copied from the trunk to give a snapshot of a site at a moment in time eg tag 1.0 – copy of trunk taken 03/11/08 – designated version 1 tag 1.1 – copy of trunk taken 05/11/08 – after changes to Fleet CRM – designated version 1.1

If you experience a problem with the current live version, it is easy to revert it to a tagged version – rolling your site back to it’s frozen state on the date it was tagged

branches

If you wanted to develop a version of the site/app that was based on the current trunk but a major change – branching off from the main development you can set up a branch based on the current trunk. Name the branch, and set up a new trunk folder

A branch is variation from the main development trunk and is unlikely to get much use.

Where to store your work

  • cd /home/www/YOUR_WORK_FOLDER

You are now in YOUR local copy folder – this is where you develop and make changes to the code.

Checking out a local copy from the repository

To checkout a YOUR Local copy of the App to a folder:

svn co file:///usr/local/svn/your_repository/trunk repository

To checkout a YOUR Local copy of the Development App to a folder:

svn co file:///usr/local/svn/your_repository/dev/trunk dev

You will also need to change the permissions on the new directory and all sub directories

chmod -Rv 777 NAME_OF_FOLDER

You can now work on the contents of this folder

Updating your local copy of project

  • Navigate into your LOCAL copy directory
  • svn st

This will return the status of your LOCAL copy. If any files are out of sync with the repository, they will be listed with a status code

Most common Codes

M      bar.c               # the content in bar.c has local modifications

X      3rd_party           # this dir is part of an externals definition

?      foo.o               # svn doesn't manage foo.o

!      some_dir            # svn manages this, but it's either missing or incomplete

~      qux                 # versioned as file/dir/link, but type has changed

A      stuff/loot/bloo.h   # this file is scheduled for addition

D      stuff/loot/bloo.h   # this file is scheduled for deletion

R      xyz.c               # this file is scheduled for replacement

I      .screenrc           # svn doesn't manage this, and is configured to ignore it

Updating your Local Copy of a project

svn up

This will update your local copy of the app to the latest version

Commit your Changes to the project

svn ci

Deleting from the project

svn delete FILENAME

Will delete file from repository AFTER a commit has been done.

Ignoring Files in the repository

There are times that you will want a directory or log file to be ignored as there will be no need to pass it to the repository.

To do this, more into the parent directory and type the following:

svn propedit svn:ignore NameOfDirectory/

This will open a text file in VI. Enter a list of files you would like Subversion to ignore. For a little more information on this [http://www.petefreitag.com/item/662.cfm Visit this link]

More Options…

There are many additional commands that can be used to control Subversion. For more details [http://svnbook.red-bean.com/ Visit the online book]