Though many teams are using Subversion (SVN) to work together and share code, version control software provides a huge number of features that are not often used. Just about any developer these days knows how to checkout a project and commit or revert changes. But a lot of teams don’t really use more advanced features like branching and tagging to organize releases.
The great thing about version control systems like SVN is that you gain a bunch of really useful functionality – even if you have only been using it for sharing code. One of those features is the ability to create an export of all modified files since the previous release. A common scenario is when the team is working on a web application and it’s time to deploy all the recent changes to the production server. An app that is distributed would normally use tags or branches to keep the versions straight. But some teams prefer to just keep moving forward on the HEAD revision and never look back. If this sounds like you, luckily SVN provides an easy way to get all changed files since your last deployment and package them up with just a few clicks.
Lets say that you last deployed your application from repository version #85. After a few weeks of development, the repository is now up to revision #178. The team has decided that the code is stable and you are ready to package up all new/changed files to transfer to the host server, client, etc.
Using TortoiseSVN, right-click on your working folder and select “Show Log” from the TortoiseSVN menu.- Click the revision that was last published (#85 in this example)
- Ctrl+Click the HEAD revision (or whatever revision you want to release ie #178) so that both the old and the new revisions are highlighted.
- Right-click on either of the highlighted revisions and select “Compare revisions.” This will open a dialog window that lists all new/modified files.
- Select all files from this list (Ctrl+a) then right-click on the highlighted files and select “Export selection to…”
You’ll be prompted for a location to save your updated files and SVN will export them all with the directory structure preserved. You can then zip this up for your client, transfer it to your host or whatever you normally do to deploy the application.
Some teams prefer to actually do an update right on the production server and simply checkout the files that way. If your hosting setup permits and you don’t mind the “.svn” files in on your server, that is another easy option for deploying code.
For even more automation, this could all be done using batch, shell or ant build scripts. If you have such a script, please feel free to post it in the comments.
BrettN
September 11, 2007 at 6:20 pm
Thanks for the post, this would appear to be exactly what I need, but I have yet to get it to work.
The TortoiseSVN windows client does not allow the export of files, only directories.
How did you get around this? What version of SVN client are you using?
Jason
September 15, 2007 at 2:28 pm
Hey Brett, I usually upgrade TortoiseSVN about every few months or whatever, but I’m not running any bleeding edge beta code or anything – I think the export features have been there for a while.
As far as the export goes – this method exports anything that has changed between revisions and it preserves the directory structure. So you have the whole folder.
If you just want the files w/o any directory structure, I’m not sure the reason you would want that, but one trick that I use in windows to “flatten” a directory structure is just use windows explorer search function to search within the folder for “*.*”. Search will return a list of all files which then you can copy the results to a single folder.
devBlog » Blog Archive » How to export only modified files with TortoiseSVN
November 2, 2007 at 9:01 am
[...] files up from a defined version of our Subversion repository, a fast Google search provided this useful article. It’s worth a reading.Mike Tags: svn, tricks Category: Software | Comment [...]
Joao
January 3, 2008 at 12:37 am
I was doing this in Win XP and it was great. Does anyone know of a SVN client that can do the similar in Linux (eg. Ubuntu 7.10)?
Jason
January 5, 2008 at 11:02 pm
I think most Linux people use the command line for SVN, but there are a few front end apps http://sourceforge.net/projects/esvn (opens source) and http://www.syncrosvnclient.com/ (commercial)
I’m not sure how to export only changed files between revisions from the command line but I would definitely like to know. If anybody knows, please feel free to leave a comment.
Wik
February 1, 2008 at 5:40 pm
About exporting only changed files between revisions from the command line.
I tried to implement it with simple shell script:
http://osmonitoring.com/mofio/
Hope this helps.
William ? Brasil
May 14, 2008 at 11:24 pm
Thanks for this useful post!
Mike
July 4, 2008 at 6:37 am
Just what I was looking for. Thanks a lot!
hamy
July 12, 2008 at 4:43 pm
Since TSVN 1.5 came out there are some minor changes. Here is a nice link to quick videos showing how to use basic TSVN features. Hope it helps you as well.
http://pollvu.blip.tv/
hamy
Simon
October 28, 2008 at 1:09 pm
So easy, thanks!
Cristian
March 24, 2009 at 10:48 am
Great post, it’s what I looking for.
Best regards.
tony petruzzi
April 9, 2009 at 6:55 pm
i’ve always wondered how to do this. saved me a ton of time and i thank you for it.
Dimas
July 8, 2009 at 8:39 am
Great post, help me very much. I’ve retweeted!
Wolfgang
July 22, 2009 at 11:51 am
Thxs for this great post, it saved us a lot of time.
Jason
August 10, 2009 at 12:43 pm
Thanks for this excellent tip!
Storm
September 21, 2009 at 10:49 pm
Thanks for your tip. It’s really cool.
josh tischer
November 11, 2009 at 4:14 pm
i have spent some time trying to figure this out when i first started using subversion a few years ago and gave up. Thanks for the reminder and solution!
Julien Falconnet
November 12, 2009 at 6:19 am
A little bash script for those missing Tortoise
http://www.falconnet.fr/Subversion-export-des-fichiers.html
jeff
November 16, 2009 at 1:46 pm
this is great. I wish, though, that I could do the same thing while selecting only certain revisions. For instance, I want all revisions having to do with a certain feature dating back 3 months, but don’t want any files associated with other features. Unfortunately the “compare revisions” menu item is not available unless you select all revisions between x and y. Any known workaround?
Jason
November 16, 2009 at 2:32 pm
hey jeff, you might want to look into tagging – http://svnbook.red-bean.com/en/1.1/ch04s06.html
Weeb
February 26, 2010 at 7:16 am
you are a star!
Marc
March 25, 2010 at 7:27 am
Hi,
Using this method, is it possible to export _all_ directories of the application? So not only the folders containing the changed files but also all other folders – which would be empty of source, since they do not contain any changed files?
Thanks,
Marc
Jason
March 28, 2010 at 4:27 pm
@Marc
Hey Marc, you can do that just using a regular old export. If you right-click and drag an SVN directory, a menu appears and it has options to export, as well as export everything including un-revisioned files.
Yura Rodchyn (rodchyn)
March 30, 2010 at 10:29 am
Thanks a lot, I need to update by FTP some changed files and need to have changed files with directory structure. Your method help me.
Thanks a lot twice!
Peter
May 11, 2010 at 10:07 am
That is just great! Found a link to this article on another blog.
Hitesh
June 7, 2010 at 5:44 am
Can any1 please tell me how to get old and new file for a particular revision number in SVN…..
Jason
June 10, 2010 at 6:55 pm
@Hitesh – there’s a lot of ways to do but it depends on what you are trying to do. check the main tortoise site and read up on the history-related commands and that should help.
Allen
June 10, 2010 at 6:22 pm
Is it possible to mark certain files/folders as not exportable? I have admin files that I dont want on a production server, but I cant find any automated way to remove them before export.
Jason
June 10, 2010 at 7:08 pm
@Allen there’s a lot of tricks for doing that. if you’re talking about config files, the way I do it is similar to the way a lot of teams deploy (wordpress for example). You have a file named something like config.default in version control with default values. When installing the first time the user must copy and rename it to something – for example config.php. And config.php is added to the svn ignore list for the repo so it will never get touched during commit or update. This way you can deploy updates without ever overwriting the config for each server installation.
If you’re talking just about folders of content that just shouldn’t get deployed, the way I would do it is just put those in a separate repo altogether, or create a branch or something so those files are not part of the deployment code.
There’s probably other ways to do it. If nothing else, just write a shell script to export and then immediately delete the files/folders you don’t want deployed.
nadshez
August 20, 2010 at 2:20 am
Thanks a lot! This is exactly what I was looking for, but couldn’t find it all the help file of tortoise. Thanks again.