Entries Tagged 'tips' ↓

howto: version control of your home directory

Well this is something I have been wanting to do for a LONG time. But so far I didn’t found a good alternative.

I’m a long time svn user but doing this with svn presented the following issues.

  • having one .svn in each folder is not an option it’s just too much hidden things everywhere plus it will cause some weird clashes
  • .svn is a pain, specially when you are grepping the source and you get double results (although I fixed this with a bash alias)
  • svn urls are confusing and long
  • ignoring files is directory based so svn status will show a ton of things

Today for some reason I started reading the mercurial documentation and it just hit me, this is what I needed. Why? well…

  • one folder with all the versioning info
  • sane ignores which are file based not path based
  • super easy backup. as the distributed version system will let me clone the repository or even better use a Bundle
  • in-place import this is a great feature svn is lacking*
  • non-intrusive

So lets get dirty first create the repository. And lets add a basic .hgignore, I got the .hgignore file tip from here which means I’m not the first one to come up with this idea. And lets commit that.


$ cd
$ hg init
$ printf "syntax: glob\n*\n" > .hgignore
$ hg commit

Now we need to figure out which files we want to get into the repository so lets figure that out.


$ ls -a1 >> .hgignore

note, that’s a “one” it will output the file in columns, if you didn’t knew that go read the man page, you will love all the switches.

Now we need to edit the .hgignore file a bit delete the following lines

*
syntax: regexp

./
../
also delete (or comment with a #) all the lines of the files you want to version (remember this is an ignore file)

then just start adding files and when you are done commit. And now you have full history of all your changes, Which is awesome for managing your config files, remembering all the tricks in your .vim or .bashrc and exporting them to other machines.

EDIT:

* in-place import means that the original code you import into the versioning system becomes a working copy.

In SVN when you do an import the original tree does not become a working copy of the code, so you have to do an import then a checkout into the same dir from which you imported. It’s very tricky and most people don’t know about it. Although There is a way to trick svn into doing it but most people don’t know about it.