Keeping Your Home Directory in Subversion

| 3 Comments | Bookmark and Share

I've heard of doing this for a long time, but always figured it'd be a huge jump to put my home directory into a revision control system. For years I've scp'd files to a new machine when I moved in and when I made changes to my vimrc or ssh config, it was hell to propagate the changes to my other machines. No more is this an issue, since I've commited my home directory. The process is really quite trivial.

I first created a subversion repository on my Linux server. A special machine isn't required, nor is root access; you just need somewhere that can be accessed with SSH from the intertubes.

~$ svnadmin create subversion

It's as easy as that. To begin with, let's create the standard subversion directory structure.

~$ svn co file://$home/subversion/ foo
~/foo$ cd foo
~/foo$ mkdir homedir
~/foo$ svn add homedir
~/foo$ svn commit
~/foo$ cd ..
~$ rm -rf foo

So now we have a repository with a homedir directory in the root; this is where all of the files from your home directory will be checked into the repository. To begin with, check out this new project into the root of your home directory.

~$ svn co file://$home/subversion/homedir .

Since there isn't anything in there, nothing will actually be checked out, but subversion will setup source control on ., your home directory. So let's add something to it. I have a .vimrc that ought to be identical across environments, so I'll check that and my .vim support directory into the repository

~$ svn add .vim*
A         .vimrc
A         .vim/colors/drew.vim
A         .vim/plugin/feraltogglecommentify.vim
~$ svn commit -m "adding stuff for the first time!"

Easy as that, all of my vim configuration files are in subversion. Now for the awesome part. Like I mentioned, I have a number of machines and, things like vim configuration files should be the same on all systems. So now, I hop onto another machine and checkout the homedir project. First I remove the existing .vim* files since they will be replaced with the repository versions.

Caligula:~$ rm -rf .vim*
Caligula:~$ svn co svn+ssh://dinomite.net/home/dinomite/subversion/homedir .
A    .vim
A    .vim/colors
A    .vim/colors/drew.vim
A    .vim/plugin
A    .vim/plugin/feraltogglecommentify.vim
Updated to revision 1.

Bam. I've now got the exact same files on both machines. If I'm at the office and find some flash vim option that I want to use, I simply add it to my .vimrc, check it in with svn ci .vimrc and when I svn up from the other machines, they'll get the new changes. In reality, I keep a bunch of stuff in my homedir subversion repository: .bashrc, .screenrc, bin directory and many others. Subversion helps me keep all of my config files in sync across a number of different machines that I use on a daily basis; if you use more than one system with any frequency, I highly suggest checking in your home directory.

3 Comments

Good post. The only thing I can suggest is that if you have read permissions allowed for your subversion repositories, especially if you've configured apache to allow web access to your repository, you may want to lock things down a bit. Adding read access only for authenticated users just for your home directory might be a good idea, especially if you check in private keys in your .ssh folder. I'm sure you've thought of that already though :)

Good point on making it public. Though I don't have public access, I'm going to set it up so that I can point the many question I get about my rc files to my svn repository. I haven't checked in any private keys, since I still think it best to generate those per-host. As Matt(http://www.asktherelic.com/) suggested, I did put my authorized_keys file into my repo, so that having password-less access to a machine is super easy.

Hi Drew! Thanks for your recommendation to try this; I set one up for myself as well. If you use a DVCS it is even easier to set up. In my case, since I'm gay for bazaar, I just ran "bzr init" in the home directory, and it was ready to add the files and commit. Then it was ready to "bzr push" as a branch to any repository I had!

Since I don't have a server I just "bzr init-repo"'d a folder on my data partition to use as a repository. It doesn't protect me against a hard drive failure but it does make it easy to get into the mix quicker when installing a new version of Ubuntu or likewise, and gives me redundant data with history in the process. Eventually I should get a cheap little server. Something like the $99 http://www.linuxdevices.com/news/NS9634061300.html with a thumbdrive would be pretty functional I suspect.

About this Entry

This page contains a single entry by Drew Stephens published on June 9, 2008 11:25 PM.

here-documents in Perl was the previous entry in this blog.

Subversion diff with vimdiff is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 5.1