Subversion Tip: How to Add External Repos To Your Project

I wanted to include some 3rd party code from another repository with my current project and store it with the rest of the files in my SVN repo. Which you can do by grabbing a copy from the 3rd party and including them when you commit your files. However, having to update and export before committing can become grueling and unnecessary. Subversion offers a simpler solution with its use of Properties. External definitions, in this case. I have a few methods laid out for you.

Command Line Method:

First, make sure you have an editor set in the Subversion config file. You can find it in:

Windows

%USERPROFILE%Application DataSubversionconfig
Mac Linux
~/.subversion/config

Now, make sure the ‘editor-cmd’ parameter is uncommented and then set it to the command line editor of your choice. Be sure to replace the word ‘editor’, that is there by default, with your selection. (i.e. -editor-cmd = vi).

Next, navigate to the folder of your working copy where you want to add the external repo to. Run ‘svn propedit svn:externals .’ This will open the editor with a temp file for you to add/edit the properties. Enter your externals like this:


local/path/ svn://external/url/ (grabs HEAD revision)
local/path/ -r# svn://external/url/ (grabs specific revision #)

Save, and exit the editor.

Update your working copy. It will now fetch the external repositories and place them into the folders specified.

Finally, commit your changes. You will see the folder you added the Properties to listed as ‘modified’. This will write your external links to the server-side repo, so the next time you or anybody else pulls from the repository they will have the externals already attached.

GUI Method – TortoiseSVN (PC)

Right Click on the Subversioned folder, and go to TortoiseSVN, Properties. Click ADD, select ‘svn:externals’ from the Property Name dropdown. Enter the mapping and url of the external reference described above. Click OK, and OK again. Run SVN Update to fetch files, and SVN Commit to add the changes to the Repository.

GUI Method – SmartSVN (Mac)

Open a project. Right click on the root or one of the folders and select EDIT EXTERNALS. Enter your local path for the mapping, and the URL of the external repository. You can select a revision or grab the HEAD by default. Click OK. Update and Commit.

Leave a Reply

Your email address will not be published. Required fields are marked *