News for hackers. Stuff that matters.
Re:Committing Without Git by tyingq on Sunday December 31, 2023 @11:21AM (#38825101)
Somewhat in the same space, I saw an interesting stackoverflow post[1] about how to generically retrieve a single file from git. Apparently since git version 1.7.9.5, you can do this:

  git archive --remote=ssh://host/pathto/repo.git HEAD README.md | tar xO
Though apparently support depends on how you're running git, and potentially some enabled server side options.

[1] https://stackoverflow.com/questions/1125476/retrieve-a-singl...

Re:Committing Without Git by matheust on Sunday December 31, 2023 @12:29PM (#38825715)
Interesting! I didn't know about the --remote flag and this usage. I would probably have done something like:

git clone --filter=tree:0 --depth=1 --sparse --no-checkout && git checkout HEAD <desired_file>

(But that would still end up fetching a few more objects than just the desired file.)

Re:Committing Without Git by eru on Sunday December 31, 2023 @11:05PM (#38829664)
The other comment above would probably also need to transmit a few more objects. At least if you are starting from a commit hash (instead of HEAD) and don't trust the server.

(I would assume git doesn't trust the server, and will verify that the chain of hashes works out.)