An Apache Subversion working copy can be created quite simply by running the ‘svn checkout’ command. However, sometimes you’ll want to have more control over the contents of your working copy; for example, when you’re working on a large project and only need to checkout a single directory.

In this post, we share two ways to get greater control over your checkout commands.

1. Checkout a particular revision

By default, Subversion performs a checkout of the HEAD revision, but in some instances you may wish to checkout a previous revision, for example when you’re recovering a file or directory that has been deleted in the HEAD revision.

To specify a revision other than HEAD, add the -r switch when performing your checkout:

svn checkout (URL) -r(revision number) (Location)

In this example, we are performing a checkout of the project as it existed at revision 10.

2. Performing Shallow Checkouts

A standard Subversion checkout copies the entire directory, including every folder and file. This can be too time-consuming if you’re working on a large project, or too complicated if your project contains many different branches, tags and directories. If you don’t require a copy of your entire project, a ‘shallow checkout’ restricts the depth of the checkout by preventing Subversion from descending recursively through the repository.

To perform a shallow checkout, run the ‘svn checkout’ command with one of the following switches:

–depth immediates: checkout the target and any of its immediate file or children. This is useful if you don’t require any of the children’s contents.

–depth files: checkout the target and any of its immediate file children.

–depth empty: checkout the target only, without any of the files or children. This is useful when you’re working with a large project, but only require the contents of a single directory.

In this example we are performing a shallow checkout on a ‘bug fix branch’ located within the branches folder, and specifying that only the immediate file children should be included (–depth files):

A standard Apache Subversion checkout includes the whole file and directory content of a specified repository. If you don’t require this level of content, you can perform a ‘shallow checkout’ that prevents Subversion from descending recursively through the repository, by restricting the depth of the checkout.

This is achieved by running the ‘svn checkout’ command as normal, but with an additional command:

–depth immediates: checkout the target and any of its immediate file or children. Note that the children themselves will be empty.

–depth files: checkout the target and any of its immediate file children.

–depth empty: checkout the target only. None of its file or children will be included in the operation.

In this example we are performing a shallow checkout on a ‘bug fix branch’ located within the branches folder, and specifying that only the immediate file children should be included (–depth files):

If you’re using SmartSVN, the cross-platform graphical client for Subversion you can set the checkout depth from the drop down menu when performing your checkout.

In our previous post, we covered performing a simple checkout with SmartSVN, using the ‘Quick Checkout’ option. In this installment, we introduce you to ‘Detailed Checkout,’ which allows you to specify which folders should be included in the working copy.

Tip. SmartSVN will automatically display the HEAD revision. However, you can use the ‘Show Revision…’ button to select revisions other than the HEAD.

4) Enter the location where you wish to create your working copy and click ‘Next.’

5) Specify whether to checkout a working copy, or export files. Click ‘Next.’

6) Review the summary and, if you are happy with the output click ‘Finish.’

7) You have successfully completed your checkout, and are ready to begin working on your project!

Get started with SmartSVN today! Visit the WANdisco website to download SmartSVN Foundation. Remember that you can evaluate SmartSVN Professional by choosing the evaluate option during the install process.

2) Select whether you wish to perform a ‘detailed checkout’ (where you can download specific files) or a ‘Quick Checkout’ which requires less configuration. In this tutorial, we’ll be performing a ‘Quick Checkout.’

3) Enter the URL of your repository, and the location where you wish to create a working copy. Click ‘Next.’

4) Review the summary and, if you are happy with the output click ‘Finish.’

5) ….and that’s it! You have now successfully performed your first checkout in SmartSVN.

Have questions about what WANdisco acquiring the SmartSVN product suite means for your SmartSVN experience? We’ve just published a handy FAQ, but please do not hesitate to Contact Us directly if you have anymore questions.

The first step to creating an Apache Subversion working copy on your local machine, is to create a repository. This is made easy with uberSVN, the free, open ALM platform.

Create Your Repository

1) In uberSVN, open the ‘Repositories’ tab. Click the ‘Add’ button.

2) Enter a name and location for your repo – this is the directory name for the repository, and will appear the end of the URL. Click ‘Next.’

3) Make sure the ‘Create new repository’ and ‘Create trunk, branches and tags directories’ checkboxes are ticked. Click ‘Done.’

4) uberSVN will automatically open a ‘Permissions’ tab, where you can configure your access rules. Permissions can either be controlled by uberSVN or through an external Authorization file.

Your repository is now ready! It can be accessed through the ‘Repositories’ tab. Be sure to make a note of the repository URL as you’ll be using it to create your working copy.

Entering Commands

In Apache Subversion, commands are entered via the terminal window. In Windows, this can be opened by pressing the “Windows key” and “r.” In the ‘Run’ dialog box enter “cmd” and click “Ok.” This will open the terminal window.

Checkout a Working Copy

Now it’s time to checkout a working copy. Enter the ‘svn checkout’ command followed by the URL of your repository and the location where you wish to create your working copy.

svn checkout (URL) (location)

In this example, we’re creating a working copy on the desktop, in a file called ‘Repo’:

More information on what’s new in Subversion 1.7.6 can be found in the Changes file. As always, if you want to get your hands on the latest, certified binaries you can do so from our website. The latest version of TortoiseSVN – 1.7.8 – is also available for download. This release is linked against Subversion 1.7.6, and features a list of bug fixes. For more information on all the updates and fixes in TortoiseSVN 1.7.8, check out the Changelog.

uberSVN ‘Chimney House’ Release 3 features many improvements and enhanced functionality for uberSVN’s ever-growing community of users. These include:

Further improvements to the way uberSVN handles LDAP and LDAPS.

Improvements to uberSVN APIs and internal development of the uberSVN SDK (public release coming soon!)

New manageAPPS page allows you to see metadata attached to your APP license, such as expiry date, number of named users, and more.

A list of bug fixes, including some fixes and alignment/mapping of the uberSVN Access Control Team Leader and uberSVN Delegated Team Admin (where uberSVN Access Control is active)

We also conducted a community poll to find out more about how you’re using Subversion. We asked what operating system your Subversion server is running on and, once again, there was a very clear winner…..

You may have already noticed that we’ve been adding new Subversion refcards. We’ve had such a great response that we’ve already put together two more – ‘All About the Apache Subversion Commit Command’ and ‘All About Checkouts.’ The first covers everything from the basic “what is a commit?” to more advanced information on editing log messages, ignoring files and directories, and an intro to hook scripts. ‘All About Checkouts’ provides a quick reference to making full use of the checkout command and understanding the messages generated under different scenarios.

We hope you’re enjoying these latest refcards, and if have any ideas for future refcards, please do not hesitate to Contact Us. If you’re after more Apache Subversion know-how, then why not take a look at our upcoming Subversion Live conference?

On the enterprise side of things, we published a new case study of our enterprise-class Subversion MultiSite product. The case study looks at how global logistics technology leader Navis – a subsidiary of Cargotec, enjoyed a 10x improvement in Subversion performance and achieved 24-by-7 uptime across all of their development sites after implementing our Subversion MultiSite solution. Read the Navis case study in full to find out more.

Also this month, WANdisco CEO and co-founder David Richards was asked to do an interview with BloombergTV – check out the full video interview below!

Finally our friend, photographer Matt Lollar popped into the office to take some new snaps of WANdisco’s Sheffield office.

Need an intro to some essential Apache Subversion commands? We got such great feedback from last month’s branching and merging refcards, that we’ve already put together two more free refcards for the Subversion community.

Meanwhile, ‘All About Checkouts’ provides a quick reference to making full use of the checkout command and understanding the messages generated under different scenarios. This refcard covers:

What is a checkout?

Performing a checkout from the command line

Performing a checkout with TortoiseSVN

How to create a nested folder

Changing the checkout file data

We’ve got even more refcards lined up for the coming weeks, so be sure to keep checking back for all the latest free training content. And if you’ve got an idea for a Subversion refcard, please don’t hesitate to Contact Us.

Need more Subversion know-how? After getting a great response from the Apache Subversion community in 2011, Subversion Live is back for 2012, bringing the Subversion community sessions covering everything from Subversion’s future, to expert-led best practices workshops, as well as the unique opportunity to meet the core Subversion committers.

In Apache Subversion, the basic workcycle follows the ‘checkout-edit-update-commit’ format.

A ‘Checkout’ is the process of pulling all the files from your repository onto your local machine, where it becomes known as a ‘working copy.’ You can then work on these files in isolation, before sharing your work with the rest of the team by ‘committing’ back to the repository.

In this week’s tip, we’ll provide a handy introduction to this basic workcycle.

Checkout

To checkout a working copy, run the ‘svn checkout’ command, followed by the URL of your repository and the location where you wish to create the working copy.

In this example, we’re creating a working copy on the desktop, in a file called ‘Repo’:

Tip, if you’re using the free uberSVN platform, you can easily find out your repository’s URL by opening the ‘Repositories’ tab.

You can now edit the files and folders in your working copy.

Update

You may be ready to share your changes with the rest of your team, but it’s good practice to perform an SVN update first. This will pull any changes your colleagues may have already committed, into your working copy, ensuring your changes fit with the most up-to-date version of the project.

To perform an update, run the ‘svn update’ command, followed by the location of your working copy.

svn update (working copy location)

Commit

Let’s assume any changes your team committed are compatible with your changes, and go ahead with the commit. When performing a commit, you should leave a log message and include as much information as possible, as this can be an invaluable source of information if you ever need to revisit this revision. When performing a commit, the log message is entered in the “–m” format (for example, -m “added ReadMe file.”)

The commit itself is performed using the ‘svn commit’ command, followed the log message and the location of the working copy.

svn commit -m “log message” (working copy location)

In this example, we are performing a commit with the log message “added Admin Guide text.”

Need more Subversion know-how? After getting a great response from the Apache Subversion community in 2011, Subversion Live is back for 2012, bringing the Subversion community sessions covering everything from Subversion’s future, to expert-led best practices workshops, as well as the unique opportunity to meet the core Subversion committers. We’re currently running a very special early bird offer: register now using the ‘earlybird’ code to get a 25% discount (note, the early bird offer ends 10th August, so you better be quick!)

Subversion is an Apache-licensed, open source software versioning and version control system that can track changes to files, folders and directories. It can also be used to recover previous versions of data, and examine the history of how a particular dataset has changed. Subversion can operate across networks, encouraging collaboration by allowing team members at various locations to work on the same set of data. Subversion can be used to manage any collection of files – web pages, binaries, documentation – not just source code!

To install, open the file to launch the setup wizard and follow the onscreen instructions to define which components you wish to install, and the install location. Enter the name of your server, the host port, and define the repository and repository location prefix – and hit install.

Alternatively, uberSVN makes Subversion easy and intuitive to use, and is free to download and free to use.

Creating your first repository

Once Subversion is installed, the first thing you need to do is create a repository. To create your first repository, open the command line, change the current directory to where you want to create your repository, and run the ‘svnadmin’ command:

svnadmin create {directory name}

Checking out a Project

To start working on your project, you must check out a working copy of the repository. This is achieved with the ‘checkout’ command:

svn checkout file {file location}

Commit Your Changes

Once you’ve made some changes to your working copy, you’ll want to push your changes to the server. Perform an “svn update” and an “svn diff” to test your changes, and resolve any warnings raised by Subversion, before committing. Once you’ve finished checking your modifications, and are ready to store the new revision in the repository, run the ‘commit’ command:

svn commit {path}

Get other people’s changes

When someone else performs a commit to the repository, you’ll need to pull those changes into your working copy, to ensure the latest trunk changes are compatible with what you’re doing in your working copy. Changes can be pulled into your working copy with the update command:

svn update {file name}
or
svn update {directory name}

Adding Files to a Project

Now you know how to checkout a working copy and commit changes back to the repository – but as you continue to develop your working copy, you may wish to add some new files to your project. When adding new files to Subversion, you need to tell the Subversion server about the files with the following command:

svn add {file name}
or
svn add {directory name}

Note that the new files won’t appear in the repository until you perform an ‘svn commit’ and send them to the repository.

Deleting Files from a Project

If at some point you want to remove these files from Subversion, run the delete command:

svn delete {file name}
or
svn delete {directory name}

Again, you must perform a commit before the file is deleted from the repository. You can also run ‘svn list’ to confirm that the file was successfully deleted from the repository.

And if you get stuck…..

The ‘svn –help’ function provides a summary of available commands or, for more information on a particular command, use:

svn help {command}

Other useful commands

svn status {path} – prints the status of working copy files and directories.

svn diff – display the differences between two revisions.

svn merge – applies the differences between two sources to a working copy path.

svn move SRC DST – think of this as ‘svn copy’ that automatically deletes the source file. This command moves a file or directory in your working copy, or in the repository. Note that Subversion does not support cross-repository moving, so it is impossible to move files across repositories with this command.

svn list – allows you to view the content of the Subversion repository, without having to download a working copy.

svn log – Subversion remembers every change made to your files and directories. This command displays the commit log messages. By default, it will show the information for the current working directory of your working copy. Alternatively, different paths can be specified.

Need more info?

On June 14th, 2012 we will be hosting a free ‘Introduction to Subversion’ webinar. This course is intended as a primer for new users or people who are thinking of making the jump to Subversion, and will cover the following topics:

Repository basics – creating and organizing

Checkouts, working folders, editing files and checkins

Reporting on changes

Simple branching

Simple merging

This webinar is free to attend, but places are limited so register now to avoid disappointment.