Remote diff similar directory trees.

We have many projects exported from Subversion on to virtual machine servers that we use for testing.  Occasionally, the project may have multiple branches and tags and it won’t be immediately evident which version is up and running.

In the case that I ran up against a great command line solution for seeing how different my checkout was from the exported version.

First, started with this gem from :

ssh {remote_host} cat {remote_file} | diff {local_file} -

What the above does is to retrieve a single file {remote_file} from {remote_host} and pipe it to diff and compare it to the {local_file}

That works great for a single file.  Now, let’s trick it out to do the entire directory tree:

# For each file in the current directory that doesn't have the word svn in it
for i in `find -type f | grep -v svn`;
  #Echo which file we're currently diffing    
  echo $i;         
  # cat the remote file and pipe it in to diff    
  ssh {remote_host} cat {external_directory}/$i | diff $i -

And voila!

Note, if you just want to see which files differ an rsync solution may be the better approach.

Donald Richardson


Second Story creates enchanting, informative, and entertaining media experiences with innovative technologies that empower connections to ideas.

Tagged with:
Posted in Technology