Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for an implementation (on Linux) of a mechanism which would automatically and transparently version any changes in a directory (recursively). This is intended to be an addition (possibly replacement if all the requested features are available) to standard versioning (SVN, git, ...)

A product on MS Windows which does this is AutoVer (to have a better idea of the requirements). I would love to have something like that but aimed at Linux in a non-graphical environment.

I saw that there are some attempts to have this functionnality on Linux, the closest one I found is autoversionning on Subversion but it is not obvious to implement on existing environments (servers where, for instance, configuration files are local).

Maybe something working with inotify?

Thank you in advance for any pointers! WoJ

share|improve this question
related: flashbake – Dan D. Dec 16 '11 at 10:06
Is there a special requirement about which software you use? Because if you're only looking to track changes you do manually (by editing files), Eclipse has this feature built-in, it's called "local history". – Stefan Seidel Feb 6 '13 at 10:48
@StefanSeidel I'm not the topic-starter, but I would prefer no-IDE solution. – Michael Pankov Feb 6 '13 at 12:57
up vote 4 down vote accepted

1. General purpose method using bazaar & inotify

This is untested by me but I found this write up that makes use of bzr (bazaar) & inotifywait to monitor a directory and version control the files in it using bazaar.

This script does all the work of watching the directory for changes:


# go to checkout repository folder you want to watch
cd path/to/www/parent/www
# start watching the directory for changes recusively, ignoring .bzr dir
# comment is made out of dir/filename
# no output is shown from this, but wrinting a filename instead of /dev/null 
# would allow logging
inotifywait –exclude \.bzr -r -q -m -e CLOSE_WRITE \
    –format=”bzr commit -m ‘autocommit for %w/%f’” ./ | \
    sh  2>/dev/null 1>&2 &
# disown the pid, so the inotify thread will get free from parent process
# and will not be terminated with it
PID=`ps aux | grep inotify | grep CLOSE_WRITE | grep -v grep | awk ‘{print $2}’`
disown $PID

# this is for new files, not modifications, optional
inotifywait –exclude \.bzr -r -q -m -e CREATE \
    –format=”bzr add *; bzr commit -m ‘new file added %w/%f’” ./ | \
    sh  2>/dev/null 1>&2 &
PID=`ps aux | grep inotify | grep CREATE | grep -v grep | awk ‘{print $2}’`
disown $PID

exit 0;

2. Managing /etc

For the special case of managing your system's /etc directory, you can use the app etckeeper.

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers including yum and pacman-g2) to automatically commit changes made to /etc during package upgrades. It tracks file metadata that revison control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It's quite modular and configurable, while also being simple to use if you understand the basics of working with revision control.

Here's a good tutorial to get you started with it.

3. Using git and incron

This technique makes use of git and incron. For this method you need to do the following:

A. Make a repo

% mkdir $HOME/git
% cd $HOME/git
% git init

B. Create a $HOME/bin/git-autocommit script


REP_DIR="$HOME/git"       # repository directory
NOTIFY_DIR="$HOME/srv"    # directory to version

GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git add .
GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git commit -a -m "auto"

C. Add an entry to incrontab

% sudo incrontab -e $HOME/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO $HOME/bin/git-autocommit

4. Using Flashbake

Another option is to use a tool like Flashbake. Flashbake is the version control system that Cory Doctorow (of BoingBoing fame) uses to write his books.

Flashbake uses git under the hood to track changes but is somewhere between doing automated backups and using a plain version control system yourself.

Cory wanted the version to carry prompts, snapshots of where he was at the time an automated commit occurred and what he was thinking. I quickly sketched out a Python script to pull the contextual information he wanted and started hacking together a shell script to drive git, using the Python script’s output for the commit comment when a cron job invoked the shell wrapper.


share|improve this answer
inotifywait+"git local", look at here: – diyism Aug 12 '15 at 4:57

Immediatly ZFS comes to mind. It can create snapshots - and there are some projects to automatically create snapshots.

share|improve this answer
I read about ZFS but it looks like it is not a stable solution for basic filesystems (at least in Linux) – WoJ Dec 15 '11 at 20:38
I would really like a solution to snap onto existing FS. – Michael Pankov Feb 6 '13 at 12:52
Perhaps this? – Zac B Feb 6 '13 at 14:36

I think you're on the right track with inotify. This article details its basic usage in a case similar to yours. I'd suggest using it either directly, or compiling a kernel-level utility like fschange. This is something of a hassle, but you could then bind the detection of changes to a git commit or similar.

Those solutions both have the issue of relying on somewhat imperfect third-party solutions. If you don't mind getting your hands dirty, NodeJS provides an excellent, cross-platform facility ( for this exact purpose. A basic tutorial on watching files for changes in NodeJS can be found here. In a few dozen lines or less, you could write something that watches a directory for files, and then shells out (via child_process) and runs a git commit or similar (or even manually increments a version file index, if you like the roll-your-own approach). is backed by inotify on linux, but is a lot more intuitive to use. There are other NodeJS projects that wrap that file-watching functionality in various levels of convenience, like this one or this one.

share|improve this answer
Still not a ready solution, and, well, I'd probably go with Python's inotify. But thanks. – Michael Pankov Feb 6 '13 at 12:55

inotify(2) on Linux won't be able to watch a large tree, but fuse filesystem (mounted in separate location) probably could handle it, by translating filesystem requests to svn or git calls, or by changing svn/git metadata directly.

This is a very interesting idea, but I hadn't heard of any existing implementations.

share|improve this answer
Let's say I have only a couple of files. – Michael Pankov Feb 6 '13 at 12:52

Such a script is not hard to write.

My favourite version control is git.

following script should do it:

git add .
git commit -am "my automatic commit"

either have that periodically check your directory - or if your editor is scriptable call after you save.

But if you do it like this it might make sense to exclude large files and maybe some "useless" like autosaves.

share|improve this answer
Yes I know that a cron-based solution is simple to implement. I am however looking for something which would version on save, no matter the save mechanism. This is also why I mentioned autoversionninf on svn as well as inotify in my question. – WoJ Dec 16 '11 at 13:03

SparkleShare ( is based on git and implements a Dropbox-Like functionality with version control, but you have to set up a ssh-server (can be localhost).

share|improve this answer
This thing is clumsy and requires a lot of setup. Besides, Dropbox functionality is unneeded. – Michael Pankov Feb 6 '13 at 12:54

I'd recommend you to try NILFS. Refer the about page and you will be quicky able to decide whther is this the one what you are looking for or not.


share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .