How to Retrieve SVN Repository URL from Existing Working Copy


3 views

When working with SVN repositories, you might inherit existing working copies where the original repository URL isn't documented. This commonly occurs when:

  • Taking over projects from other developers
  • Migrating to new development machines
  • Recovering from lost documentation

The simplest way to find the repository URL is using the svn info command. Navigate to your working copy directory and run:

svn info | grep "URL:"

For Windows systems using Command Prompt:

svn info | find "URL"

For more comprehensive details, run the full info command:

svn info
Path: .
Working Copy Root Path: /path/to/your/working/copy
URL: https://svn.example.com/repo/trunk/project
Relative URL: ^/trunk/project
Repository Root: https://svn.example.com/repo
Repository UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Revision: 12345
Node Kind: directory
Schedule: normal
Last Changed Author: developer
Last Changed Rev: 12345
Last Changed Date: 2023-01-01 12:00:00 +0000 (Sun, 01 Jan 2023)

If you don't have command-line access or prefer GUI tools:

Using TortoiseSVN (Windows)

1. Right-click the working copy folder
2. Select "TortoiseSVN" → "Properties"
3. View the "Subversion" tab

Checking SVN Metadata Files

SVN stores repository information in the .svn directory. You can examine:

cat .svn/entries
# Or for newer SVN versions:
sqlite3 .svn/wc.db "SELECT root FROM REPOSITORY"

Here's how to use this information to create new checkouts:

# For the root URL
svn co https://svn.example.com/repo

# For a specific branch
svn co https://svn.example.com/repo/branches/feature-xyz

# For a specific revision
svn co -r 12345 https://svn.example.com/repo/trunk
  • If svn info fails, verify you're in a valid working copy
  • Check for network connectivity to the repository
  • Ensure your SVN client version is compatible with the working copy format
  • For relocated repositories, use svn relocate if needed

For scripting purposes, you can extract the URL programmatically:

#!/bin/bash
REPO_URL=$(svn info --show-item url)
echo "Repository URL: $REPO_URL"
svn co $REPO_URL new_working_copy

When inheriting existing Subversion (SVN) checkouts from colleagues or previous setups, you'll often need to determine the original repository URLs to replicate the same checkout on another machine. Here are reliable methods to extract this crucial information.

The most straightforward approach is using SVN's built-in info command. This displays comprehensive metadata about the working copy.

svn info /path/to/your/working_copy

Sample output showing the key URL field:

Path: .
URL: https://svn.example.com/repos/project/trunk
Repository Root: https://svn.example.com/repos/project

For cases where the SVN client isn't available, you can inspect the hidden .svn directory:

cat /path/to/working_copy/.svn/entries

Or for newer SVN versions (1.7+):

sqlite3 .svn/wc.db "SELECT root FROM REPOSITORY"

After obtaining the URL, verify it's correct by listing the repository contents:

svn ls https://svn.example.com/repos/project/trunk

Let's walk through a complete example for clarity:

# Navigate to existing checkout
cd ~/projects/legacy_code

# Get repository information
svn info

# Sample output interpretation:
# URL: https://svn.company.com/svn/main_repo/branches/stable-2.1
# This is what you'll use for your new checkout

# On new machine:
svn co https://svn.company.com/svn/main_repo/branches/stable-2.1

When dealing with multiple checkouts (like in the user's case), you can automate the URL retrieval:

for dir in /path/to/checkout1 /path/to/checkout2; do
    echo "Repository URL for $dir:"
    svn info "$dir" | grep '^URL:'
done
  • If svn info fails, ensure the working copy isn't corrupted
  • For very old SVN versions (pre-1.7), check the format of .svn/entries
  • Remember that the URL might reference a specific branch/tag