/git-rofs

Mount Git repositories as read-only filesystems at arbitrary commits

Primary LanguageGoGNU General Public License v3.0GPL-3.0

Git ROFS

Git ROFS is a read-only FUSE filesystem for Git repositories. It is more or less equivalent to a read-only version of git checkout, except it doesn’t do any writes to disk.

Use

The requirements to build the program are:

  • go >= 1.12

  • libgit2 >= 0.27

  • libfuse

The Go dependencies use CGo and may require pkg-config and a C compiler as well. To build the program, run:

make

To install it to $prefix (default $HOME/bin):

make install

Run the program with:

git-rofs [OPTION]... ROOT MOUNTPOINT

ROOT is the Git repository to look at. MOUNTPOINT is a directory where the repository should be mounted.

By default, the program will mount the given repository at its current HEAD. This is not very interesting. To mount it at anything that git rev-parse can resolve into a commit hash, use the -commit REF option.

Run git-rofs -h or git-rofs -help to see all available options.

Possible applications

  • Look at the state of a repository at various points in its history.

  • Run static analysis at different points in repository history in parallel to see how metrics have evolved.

  • Keep a read-only version checked out for code searching while developing in a worktree.

Possible improvements

  • Change the reference that is checked out at runtime via some IPC mechanism.

  • Create mountpoints if they don’t exist. Clean them up on exit.

Prior art

I wrote an earlier iteration of the same idea in Python. It was uncomfortably slow.

Contributing

Development happens in this Github repository. Please file issues for any bugs or features. Pull requests are very welcome.

License

This project is licensed under the GPLv3.