Why do we need a remote?
chiphogg opened this issue · 2 comments
In reading the instructions, I was surprised by the step to set up a remote. My mental model for the intended use case was the ability to use git's excellent version control capabilities locally, in a repo that has large files. (For example, a git repo to track personal notes, stored as a collection of markdown files and images.)
After research and reflection, I believe the reason is because git lfs
doesn't actually push the files to the LFS repository until you push your commits to a remote. I inferred this from reading this git LFS doc.
If one doesn't want to use a remote server at all, I believe one can simply create a "local remote" by making a folder, doing git init --bare
, and setting that folder as the remote, and pushing to it.
What happens if we never push, because we're purely using git
for version control? Based on reading that same LFS doc, I believe what would happen is that the file would get stored in the LFS cache, in .git/lfs/
, at commit time. It would not be pushed to the folder we designated for our LFS store. As soon as we push our commits, the files get pushed from the LFS cache to the LFS store.
I tried this out, and it seemed to work as I expected.
Does my understanding sound about right? Have I missed anything significant?
If I'm right: do you think it is worth saying something in the README about why we need to set up the remote, to help other users who are surprised as I initially was? (Maybe you can just link to this issue for the explanation if I'm not too far off. 🙂)
Conceptually the idea of the remote is the same as for any git repo: to share with others. With LFS it gains an additional property, which is not present in standard git: your local LFS store may not be complete (you may not have all the binaries locally).
lfs-folderstore's model is not about using git locally. It's about being able to use a plain git remote that doesn't have LFS API support, but syncing the LFS content via regular file shares instead. Therefore you can use e.g. a bare SSH repo on a remote plus a NAS drive as a full LFS system.
If you want to use LFS git repos purely locally that's fine, they'll behave much like regular local git repos, just with an additional bunch of content in .git/lfs/objects. But once you need to share with someone else, you need a remote - the "full fat" LFS way to do that is to send LFS content up to a REST API on a server, lfs-folderstore just lets you replace that with a file share.
Great, thanks for explaining!