Can we set a single file as external in Subversion?
4 Answers
Yes, it's possible with svn 1.6. It's documented in the nightly build version of the svn book.
But even though file externals are working, you should only do it with text files (for now) because binary files won't work correctly as file externals.

- 43,293
- 10
- 75
- 117
-
4the issue with binary files (http://subversion.tigris.org/issues/show_bug.cgi?id=3368) is fixed – sdu Sep 17 '09 at 07:50
-
5still one should note, that external files can only be included from the same repository as the folder that holds the externals-definition – Janosch Aug 08 '12 at 12:21
-
Janosch: that's not true. file-externals can come from any repository. – Stefan Aug 08 '12 at 14:35
-
2Stefan, according to the documentation to which you linked, Janosch is correct. Quoting from the documentation: "File externals cannot refer to files from other repositories." That's further confirmed by the error messages I get when I try to external files in another repo: `'http://my.repo.server/src/external_repo/file1.html' is not in repository 'http://my.repo.server/src/current_repo'` Can you elaborate on how to get files from other repositories to be externals? – Peter Sep 19 '12 at 18:02
-
@Stefan Same here - does not seem to be possible from another repository in 1.6 – codecowboy Oct 04 '12 at 08:19
-
1@Peter just tried it with 1.8 and it is still a limitation. The definitive answer then is to external a directory instead and ignore the other files in there. – gbjbaanb Nov 11 '13 at 08:23
-
1Any news about this? Is there a feature request for this, which i dont find? – Janosch May 02 '14 at 15:25
As mentioned in the first answer, SVN Externals are documented in Chapter 3 of the SVN Book, and quite a few syntax examples are given there.
In addition, this note is given:
"Because the svn:externals property has a multiline value, we strongly recommend that you use svn propedit instead of svn propset."
In my experience testing Tortoise SVN v1.9.6 and svn.exe v1.9.5, the results are as-documented.
- Bringing in an external folder with all its files works.
- Bringing in a single file from the same repo works.
- Bringing in a single file from a different repo fails and this limitation is documented in the SVN book.
This leads to a clumsy workaround. If you control both repos, you can clone an individual file into its own folder in the source repo (by Externals of a single file WITHIN a repo), and then Externals it across repo borders into the target repo by bringing in its entire folder, which contains only a single file.
Docs for doing this with the Tortoise SVN client are on tortoisesvn.net.

- 185
- 2
- 7
I couldn't find a good example about how to create a svn file external. So I am providing an example here so it can be useful for others.
The format is
svn propset svn:externals "<local file> <remote svn file>" <local dir>
For e.g. following command
svn propset svn:externals "my.cfg https://myserver/my/svn/location/my_sample_file.cfg.template" my_folder
will create the file https://myserver/my/svn/location/my_sample_file.cfg.template under my_folder
as my.cfg
. Here obviously, I assume you already have the folder my_folder
under your current directory which is under svn.

- 154
- 5
-
1Strange, the SVN docs claim file externals are not possible across repositories. – 0xC0000022L May 31 '16 at 19:07
-
Nikita Bosik's answer blelow is preferred as it allows relative paths. – gerardw Mar 20 '17 at 15:43
For SVN 1.9.4 the syntax is like folder's one:
svn propset svn:externals <remote file> <local file>
E.g., this will create file local.txt
in the current directory referencing to file.txt
:
svn propset svn:externals ^/trunk/path/to/file.txt local.txt

- 851
- 1
- 14
- 20