0

I have a git repository, and I would like other users to be able to read (only) any file of the master branch without having to run git clone.

One option is to mount the repository with gitfs. Is there any better option? Is there a reason to avoid this and make users clone every time?

Yariv
  • 381
  • 3
  • 11
  • Could you elaborate why you want to omit git clone? Cannot they e.g. use GUI that hosts your repo like github.com? – kosciej16 Jan 09 '22 at 19:51
  • Git definitely does not provide this ability. Note that a repository doesn't contain *files*, at that level anyway: it holds *commits*. The *commits* then hold files. Branches, in a sense, don't even *exist*. A branch name just selects some particular *commit* (which does exist). You then extract the entire commit (`git checkout` or `git switch`), and then, from there, you have all the files from that commit. To get one file, you extract the entire commits, then throw out the repository and all files except the one file you wanted: not very efficient. – torek Jan 10 '22 at 04:36
  • You *can* use `git archive` to make Git build an archive (tar or zip file) from a commit, or from some subset of a commit—including as little as just one file—which you can then un-archive. But even that's not terribly efficient. – torek Jan 10 '22 at 04:37
  • You may well find some library or other software for extracting individual files from some specific commit, such as the latest commit on some named branch. But that's not what StackOverflow is about—you'll want some other web site for such questions. – torek Jan 10 '22 at 04:38

0 Answers0