Copying only modified files under SVN

If you are web developer and you are working with Subversion, then you probably did this thousand of times. You have modified some files (probably a lot of them), and after that you have to update your dev/prod server. It can be pain in the ass, if you have large repository with complex directory structure.

The best solution will be to have working copy on dev/prod server and use svn checkout or svn export. But sometimes it won’t work, e.g. if your repository is not accessible from your server, or you don’t want to commit your files without testing them on server or whatever else.

If you are working under *nix, here’s useful command that will facilitate this tedious task:

svn status | grep '^[ADMR]' | cut -b 8- | xargs -I '{}' cp --parents {} /temporary/destination/dir

Let’s see what it means. First, we take status of each file/directory in the working copy, then filter only modified/added/deleted/replaced files (it’s /^[ADMR]/ regex for the first column in svn status result). Then remove column with files statuses and pass it to copy command preserving directory structure. That’s it.

Tags: ,

AddThis Social Bookmark Button

Leave a Reply