has anyone made a read-only FUSE filesystem for a git repository where every commit is a folder and the folder contains all the files in that commit?

the idea is that you could just run `cd COMMIT_ID` and poke around instead of checking out the commit

and maybe the branches could be symbolic links to the commit folders?

guys this is such a fun idea I cannot believe people are in the replies trying to explain to me why they think it is impractical

the whole point of computers is to do impractical things and see what happens

seems like the answer is yes!

- https://github.com/fanzeyi/giblefs (fuse implementation in rust where every commit is a folder)
- https://orib.dev/git9.html (for plan 9)

would love to hear about any others

GitHub - fanzeyi/giblefs: Mapping a Git repository as a virtual filesystem

Mapping a Git repository as a virtual filesystem. Contribute to fanzeyi/giblefs development by creating an account on GitHub.

GitHub

ok I got extremely nerd sniped and made my own version of this “filesystem where every git commit is a folder" thing https://github.com/jvns/git-commit-folders

I wrote a FUSE version and an NFS version that I think will be easier for mac users to use. it definitely does not work on windows.

it probably has about 5 million bugs but it seems to kind of work

GitHub - jvns/git-commit-folders

Contribute to jvns/git-commit-folders development by creating an account on GitHub.

GitHub

the main reason I've found this "all your git commits are folders" feature to be useful is for searching past code: I can run `grep someFunction branch_histories/main/*/commit.go` to find the old version of someFunction I deleted. There are other ways to do that in git but this is easier.

or if I want to just quickly look at a file on another branch to copy a line from it, I can run `vim branches/other-branch/go.mod`

curious about other use cases

(from https://github.com/jvns/git-commit-folders)

GitHub - jvns/git-commit-folders

Contribute to jvns/git-commit-folders development by creating an account on GitHub.

GitHub

@b0rk if I want to find a past piece of file contents on a known branch, there are existing ways, like git log -G. I think where your thing would be *really* useful is if I can't even remember which *branch* it is.

"I remember that somewhere among my 50 half-finished dev branches I added a function called do_useful_thing(), but arrgh, which one?"

@simontatham @b0rk

There is "git grep" for that.

@albertcardona @simontatham I thought git grep only searches the current working tree

@b0rk @albertcardona you can make it search a specific commit in place of the worktree, so you could do something like

for r in $(git rev-list <params>); do git grep search_term $r; done

but it's cumbersome, and doesn't annotate the results with which commit they came from, unless you add a further "| sed" or some such. But with a git-fuse filesystem you could do this, which is short and simple and does show where it found the term:

grep search_term gitfs/*/*/foo.c