4

I am after a tool that can provide me with incremental file history (for text-based source files). I use version control but would like more history.

This history only needs to be temporary and span the gap between commits. Sublime already lets me diff the editor contents to what is saved. So I would like get a change record per save.

Many IDEs have this feature. For example IntelliJ's local history. However I would like to do this independent of an IDE or text editor. I am after a dedicated tool that can run on Linux.

One approach would be to use rsync and periodically take backups. There are even tools that do this such as tym. But this would make it difficult to search through the list of changes. I would like something that has a Git style history and can use a Meld style interface to diff changes.

0

2 Answers 2

2

The way to do keep versions of files automatically and independently from the application is at the filesystem level. There's a FUSE filesystem for that: copyfs. Copyfs provides a view of an existing directory tree (stored on the filesystem of your choice) where all past versions of each file are kept available. Opening files normally yields the latest version; the command line tool copyfs-fversion lets you access past versions.

To compare a past version with the current version, run copyfs-fversion -l VERSION-NUMBER FILE to lock the old version, make a copy of it, then run copy-fversion -r *FILE* to return to the latest version. There's also at least one patched version, fuse-copyfs, which extends copyfs-fversion with an option -d to diff versions (among other things).

Copyfs lacks a way to purge old versions.

Alternatives (also based on FUSE) are mentioned in Linux File Versioning? on Unix & Linux.

2

You could use git itself, locally - without the need of a server, to track the history. If you have git installed in your computer, issue the git init command from inside the directory, to initialize a git repository in your existing directory. Now, add the choice of your files with the add command, eg: git add *.py. Commit the current version with say, git commit -m 'initial version', and continue working on the files. Fire the commit command at your desired milestones.

You can use any Git UI to explore this local repository and view file history with compatible tools.

==Additional information below, on automation, per Angelo's request==

The git commit action can be automated upon file saves, with scripting and o/s capabilities or additional software, but would probably be an overkill. But, just for exploring the option,

  1. In Linux, iNotify could be leveraged to automatically fire up a script at system startup to watch changes on folders in a specified list, and fire the git commit command when changes occur.
  2. In Mac, a 'Folder Action' can be setup to watch for changes in a folder, and fire up a script containing the git commit action upon a qualifying event
  3. In Windows, either you could brew up a simple C# program using the FileSystemWatcher , or use one of the many freeware programs available for this purpose (eg: Watch 4 Folder), and trigger the git commit action in response.
2
  • 1
    Could you add a description how this could be automated for every change that happens to the file? The local history of the IDEs the OP mentions does not need any additional tool. Is there a way to hook into the file system changes? Oct 22, 2014 at 14:53
  • 2
    @AngeloNeuschitzer , have updated the answer with suggestions on automation Oct 22, 2014 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.