News for hackers. Stuff that matters.
Re:Mounting Git commits as folders with NFS by okl on Tuesday December 05, 2023 @03:15AM (#38528225)
Git already has a similar feature. It's called worktree https://git-scm.com/docs/git-worktree

For example: `git worktree add <folder> <commit-hash>` checks out that commit in that folder.

Re:Mounting Git commits as folders with NFS by vnorilo on Tuesday December 05, 2023 @04:08AM (#38528522)
TFA is for the actual data in the commit, not a parallel worktree.
Re:Mounting Git commits as folders with NFS by Vohlenzer on Tuesday December 05, 2023 @04:38AM (#38528690)
I find it helpful to keep a few worktrees around for common tasks.

This saves me from throwing away my working copy when I switch to a different task;

  /source/repos/AcmeCorp            2fddd74f9a [bug/CurrentWork]
  /source/repos/AcmeCorp-hotfix     27175cf6c5 [hotfix/2023-11-27.1]
  /source/repos/AcmeCorp-master     016ca20b75 [master]
  /source/repos/AcmeCorp-reference  454be5348d [feature/RecentReviewedWork]
  /source/repos/AcmeCorp-release    95027177d7 [release9.12.0]
Re:Mounting Git commits as folders with NFS by masklinn on Tuesday December 05, 2023 @05:19AM (#38529051)
Worktrees require checking out each branch individually.

And they’re something of a pain in the ass to manage as you can’t have two worktrees to the same branch.

So for temporary querying across a few branches doing clones is a lot easier (git will hardlink when cloning on the same FS so performances are not an issue, and you can just delete the scratch clones afterwards without the need to prune the worktrees), and if you regularly need to query things across a lot of branches worktrees are unusable.