Get files from subversion without creating a sandbox using svn export
One of the first things people learn about using subversion is how to do a "checkout" using svn co. The svn checkout command pulls files from the subversion repository into your "sandbox" and in so doing creates what subversion calls a "working copy". A working copy includes a .svn directory in every subdirectory of the working copy, which is chock full of directories and files that svn uses to determine what you're doing in your sandbox.
A "working copy" is designed to be just that -- a copy of the source tree built with the assumption that you will be making changes and committing them back to subversion. But what do you do if you want the files, but you don't need or want a sandbox?
A "working copy" is designed to be just that -- a copy of the source tree built with the assumption that you will be making changes and committing them back to subversion. But what do you do if you want the files, but you don't need or want a sandbox?
There are a number of cases where you don't want a working copy but still want the source code. To support this frequent requirement, Subversion provides the svn export command which the manual describes as "Export a clean directory tree." A "clean directory tree" is simply the files you would otherwise get from an svn checkout, sans everything extra that a working copy requires.
Let's say that you have a new server to setup, and you want to configure it to support the Zend Framework. You could change to the include directory for php on your server (on some system this might be /usr/include/php) and then use svn export to get a nice clean copy of the framework for use in your applications.
svn export http://framework.zend.com/svn/framework/standard/tags/release-1.10.0/library/Zend/ Zend
You can use the -r (revision) flag with the export command, but you'll still get the entire tree, as it existed in the repository when that revision was committed.
Let's say for example that you only want some files from a particular location (Zend/Feed) in the source tree, as they existed at revision 21000. Again using the Zend framework as an example:
svn -r 21000 export http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Feed Feed
If the Feed directory already exists, you will receive an error:
svn: Destination directory exists; please remove the directory or use --force to overwrite
This can be over ridden by following their advice and simply adding the --force flag.
svn export can be used to automate production deployment systems, but it's important to remember that even if you are using svn export to update source code, you're still going to get everything from that repository location on down, since again this is not a sandbox. If you need a tool to facilitate updating servers in a cluster, svn export can still be very useful, but you might want to combine its ability to get files from a repository, with a tool like rsync which is able to selectively update files determining first whether or not they have actually changed. Use svn export to pull a fresh copy of all the source files into a staging directory and then using rsync to only move files that have actually been updated.
To summarize, svn export is a tool that will pull files from a subversion repository without making an svn working copy. Unlike svnlook, svn export works with all svn repository paths, and it is a useful command for people simply wanting to get the current version of project files, or for developing a build automation or cluster deployment tool.
Let's say that you have a new server to setup, and you want to configure it to support the Zend Framework. You could change to the include directory for php on your server (on some system this might be /usr/include/php) and then use svn export to get a nice clean copy of the framework for use in your applications.
svn export http://framework.zend.com/svn/framework/standard/tags/release-1.10.0/library/Zend/ Zend
You can use the -r (revision) flag with the export command, but you'll still get the entire tree, as it existed in the repository when that revision was committed.
Let's say for example that you only want some files from a particular location (Zend/Feed) in the source tree, as they existed at revision 21000. Again using the Zend framework as an example:
svn -r 21000 export http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Feed Feed
If the Feed directory already exists, you will receive an error:
svn: Destination directory exists; please remove the directory or use --force to overwrite
This can be over ridden by following their advice and simply adding the --force flag.
svn export can be used to automate production deployment systems, but it's important to remember that even if you are using svn export to update source code, you're still going to get everything from that repository location on down, since again this is not a sandbox. If you need a tool to facilitate updating servers in a cluster, svn export can still be very useful, but you might want to combine its ability to get files from a repository, with a tool like rsync which is able to selectively update files determining first whether or not they have actually changed. Use svn export to pull a fresh copy of all the source files into a staging directory and then using rsync to only move files that have actually been updated.
To summarize, svn export is a tool that will pull files from a subversion repository without making an svn working copy. Unlike svnlook, svn export works with all svn repository paths, and it is a useful command for people simply wanting to get the current version of project files, or for developing a build automation or cluster deployment tool.
Defined tags for this entry: php, subversion, svn, svn checkout, svn co, svn export, web development, Zend Framework
Comments
Display comments as Linear | Threaded