Sunday, March 14, 2010

git snapshot

I've just uploaded a new tool, git snapshot, which lets you routinely capture snapshots of your working directory, and records them in parallel to your explicitly recorded history.

The snapshot revisions stay out of the way for the most part, but if you need to view them you can look at them, for example using gitx refs/snapshots/HEAD

For me this is primarily useful when I'm sketching out a new project and forgetting to commit anything. When working on a large patch I usually use git commit -a --amend -C HEAD fairly often, which in conjunction with git reflog provides similar safety. However, git snapshot is designed to work well in either scenario.

I have a crontab set up to use mdfind so that all directories with the red label are snapshotted once an hour.

3 comments:

melo said...

Like this? http://search.cpan.org/dist/App-CMAM/

nothingmuch said...

Not really, the main goal was to record it along side the "real" history, so the workflow isn't interrupted (I don't have to go back and squash all the automatic commits, I just pretend they didn't happen if I don't need them).

Though the file monitoring stuff is definitely useful. Maybe you could make CMAM run either git snapshot or git commit depending on some flag?

Patrick Ohly said...

Very useful, thanks. I was about to write something like this myself when I found your tool - saved me a lot of trouble :-)

Only one question about the "stay out of the way" part: I use "gitk --all" a lot to review feature branches. The snapshots show up in gitk, which is both good (if I ever need to find something in them) and bad (most of the time, because the display becomes a bit cluttered).

Do you have any idea how I can teach gitk to ignore the snapshots?