How to read/extract the content of a file from a subversion repository without checking out the whole directory

Sometimes, instead of downloading a whole repository from subversion or even some directory of the repo to read a file, you may want to simply show the content of the file in the terminal so you can easily see what you need. Fortunately, subversion offers an utility to do it, this utility is svn cat.

SVN Cat allows you to print the content of a file in the terminal from a subversion repository quickly, just provide the SVN URL of the file that you want to read as argument and the tool will print it in the terminal:

svn cat svn+ssh://user@svnserver.com/var/www/vhosts/yourrepository/file.txt

This works as well for the SSH and HTTPS protocol, asking for credentials if needed. In some cases you will need as well to show the content of the file from a specific revision. In that case, just specify the revision number with the r argument, e.g for the revision number 3:

svn cat -r 3 svn+ssh://user@svnserver.com/var/www/vhosts/yourrepository/file.txt

For more information about the cat utility of SVN, please read the official docs here.

This could interest you
Become a more social person