Skip to content

Instantly share code, notes, and snippets.

@micimize
Last active February 20, 2024 23:24
Show Gist options
  • Save micimize/f9b12540e26d32430dc0dd77b399aba9 to your computer and use it in GitHub Desktop.
Save micimize/f9b12540e26d32430dc0dd77b399aba9 to your computer and use it in GitHub Desktop.
Idea for a standalone, automatic git-based workspace history tracker/navigator

Given the interest here I wanted to mention an idea I had for implementing this as a standalone utility:

  1. Init a bare repo in projectroot/.ghistory + a background job that auto-commits to it with high frequency (< 1s) without touching the primary working tree
  2. Derive tree of file edits/states from ghistory repo for navigation/checkout, maybe as a git tree
  3. Periodically compress/clean the ghistory tree to most 5min intervals

I know it's a fundamentally different approach & requires saving, but it'd have the benefits of being editor agnostic and eternal, as well as automating away the need for anxious WIP commits.

IDK if I'll ever implement this myself so I wanted to put the idea out into the aether.

Edit: In retrospect a git notes namespace would probably make more sense (https://alblue.bandlem.com/2011/11/git-tip-of-week-git-notes.html)

@maresb
Copy link

maresb commented Feb 25, 2023

Interesting idea.

So would you detect "undo"s entirely by context? Like in the compress/clean step? I suppose you could look at the content hash to see if there's a state which previously occurred.

@micimize
Copy link
Author

@maresb context is what I was thinking initially – maybe something like edit distance + time difference. But, when you're using the tool's interface, it could just do git operations for undo, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment