You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No way to share large content between repo directories. #766
My objective in our CI is to be able to sync multiple branches one to one with folders, but right now that means a new download of our large content - roughly 15 GB - for every new branch. Seems like I should be able to move the storage for the local media and it's metadata out to a shared folder which git-lfs could leverage. As far as I can tell there is no way to adjust the local media directory that reports from "git lfs env". If so then this might just be a documentation clarity issue. I'm not certain if there are implementation details preventing this either.
This would lead to a shared LFS directory on each CI server. I also wanted to experiment with some kind of LFS proxy, which could let you have your own shared storage for ALL your CI servers. This could greatly reduce the bandwidth with your upstream LFS server if it isn't already hosted inside your network.
changed the title [-]No way to share large content between repo directoies.[/-][+]No way to share large content between repo directories.[/+]on Oct 21, 2015
Have you tried using git worktree? Git LFS already supports that so if you create a separate worktree on the other branch, the lfs/objects directory will be shared between them just like the git repo itself. Another advantage is that this will automatically be respected by other functionality like the upcoming git lfs prune.
That's a good suggestion, but my applications is slightly different. I want a local cache of all my objects across all my projects. We have large binaries that are shared across multiple projects and get added and removed fairly frequently. Ideally there would be a global LRU cache of objects. The folder for this cache could be configured per project.
Multiple clones for a CI server. Git worktrees may work here if the CI server supports them.
A shared object directory for multiple repos. Doable, but the upcoming prune command (Prune feature (delete old / unreferenced local objects) #742) would have to be disabled for every repository. Otherwise one repository might remove every other repository's objects because they're not referenced in the first repository's history. This is definitely a more technical option, and users would be responsible for managing this shared directory according to their needs.
Git worktree looks like a potential solution, I'm using Jenkins and will have to dig into whether I can use this easily in my case. If not, I'm definitely willing to start looking at a Git-lfs solution. Caveats: I'm new to Go and new to Git. If someone else wants to pick this up before that, just let me know here. I'll get back to this thread next week after digging into the worktree solution and let you know.
A shared object directory for multiple repos. Doable, but the upcoming prune command (#742) would have to be disabled for every repository.
You mean unrelated repos? If they were required to register with the shared directory somehow (just a dir with files that are pointers back to the repo) then prune could follow that and behave like it does for worktree, including those other repos in the retain set. Would need an equivalent of git worktree --prune to tidy up references to repos that went away though, and moving repos could be an issue.
In git-lob I supported a shared object store for many repos (related or not) and used hard links to track how many references existed to each object. Basically each repo used its own local object store but the files were really hard links to the shared directory. Advantage was moving folders around didn't break anything but it did complicate the storage engine somewhat (and limit support to filesystems with hard link support - I had to write a hard link implementation for Windows/NTFS). Also not sure how this would interoperate with worktrees now (this was before they were added to git).
What if the shared object directory could be provided as an alternative? Similar to git clone reference repository. I.e. the objects would be searched from:
local LFS storage directory
alternative object storage directory if configured
LFS server
It would be very flexible setup for object sharing yet it should not cause any problems with prune command.
Old question, but I'm also confused about configuration in shared directory (for build controllers). I was able to find solution only after research in source code in IDE.
In source code: config.go
// New initializes a new *Filesystem with the given directories. gitdir is the// path to the bare repo, workdir is the path to the repository working// directory, and lfsdir is the optional path to the `.git/lfs` directory.funcNew(gitdir, workdir, lfsdirstring) *Filesystem {
fs:=&Filesystem{
GitStorageDir: resolveGitStorageDir(gitdir),
}
fs.ReferenceDir=resolveReferenceDir(fs.GitStorageDir)
iflen(lfsdir) ==0 {
lfsdir="lfs"
}
iffilepath.IsAbs(lfsdir) {
fs.LFSStorageDir=lfsdir
} else {
fs.LFSStorageDir=filepath.Join(fs.GitStorageDir, lfsdir)
}
returnfs
}
Hi @dtulepov, these are all great references. I'm not quite sure about your specific question: are you having trouble configuring lfs.storage, or is something not behaving as expected? Either way, I'd be more than happy to help, but I think that a new issue would be the best place to discuss.
Activity
technoweenie commentedon Oct 21, 2015
I'd be into allowing the
lfs.LocalMediaDirconstant to change based on an environment variable. It wouldn't be difficult:https://github.com/github/git-lfs/blob/f56cd54ad7f8e13df6415a568f5681394bd44b31/lfs/lfs.go#L99-L119
This would lead to a shared LFS directory on each CI server. I also wanted to experiment with some kind of LFS proxy, which could let you have your own shared storage for ALL your CI servers. This could greatly reduce the bandwidth with your upstream LFS server if it isn't already hosted inside your network.
jwittner commentedon Oct 21, 2015
Shared folders and the environment variable could get you close to a single storage location solution.
jwittner commentedon Oct 21, 2015
What about driving lfs.LocalMediaDir via the git-config - it would match the ways we configure the endpoint in git-lfs.
git config --add lfs.localMediaDir ?
technoweenie commentedon Oct 21, 2015
I like the
git configoption. Easy to configure per repo or globally 👍[-]No way to share large content between repo directoies.[/-][+]No way to share large content between repo directories.[/+]tristanz commentedon Oct 21, 2015
I have workflows that would also be helped by this option, so 👍 .
sinbad commentedon Oct 23, 2015
Have you tried using
git worktree? Git LFS already supports that so if you create a separate worktree on the other branch, thelfs/objectsdirectory will be shared between them just like the git repo itself. Another advantage is that this will automatically be respected by other functionality like the upcominggit lfs prune.https://git-scm.com/docs/git-worktree
tristanz commentedon Oct 23, 2015
That's a good suggestion, but my applications is slightly different. I want a local cache of all my objects across all my projects. We have large binaries that are shared across multiple projects and get added and removed fairly frequently. Ideally there would be a global LRU cache of objects. The folder for this cache could be configured per project.
technoweenie commentedon Oct 23, 2015
Sounds like there are two use cases here:
prunecommand (Prune feature (delete old / unreferenced local objects) #742) would have to be disabled for every repository. Otherwise one repository might remove every other repository's objects because they're not referenced in the first repository's history. This is definitely a more technical option, and users would be responsible for managing this shared directory according to their needs.Anyone want to take this on?
jwittner commentedon Oct 24, 2015
Git worktree looks like a potential solution, I'm using Jenkins and will have to dig into whether I can use this easily in my case. If not, I'm definitely willing to start looking at a Git-lfs solution. Caveats: I'm new to Go and new to Git. If someone else wants to pick this up before that, just let me know here. I'll get back to this thread next week after digging into the worktree solution and let you know.
sinbad commentedon Oct 26, 2015
You mean unrelated repos? If they were required to register with the shared directory somehow (just a dir with files that are pointers back to the repo) then prune could follow that and behave like it does for worktree, including those other repos in the retain set. Would need an equivalent of
git worktree --pruneto tidy up references to repos that went away though, and moving repos could be an issue.In
git-lobI supported a shared object store for many repos (related or not) and used hard links to track how many references existed to each object. Basically each repo used its own local object store but the files were really hard links to the shared directory. Advantage was moving folders around didn't break anything but it did complicate the storage engine somewhat (and limit support to filesystems with hard link support - I had to write a hard link implementation for Windows/NTFS). Also not sure how this would interoperate with worktrees now (this was before they were added to git).jwittner commentedon Oct 28, 2015
Worktrees are working for me so I'm not compelled to add this functionality right now. @sinbad for the win.
jlehtniemi-broadsoft commentedon Nov 25, 2015
What if the shared object directory could be provided as an alternative? Similar to git clone reference repository. I.e. the objects would be searched from:
It would be very flexible setup for object sharing yet it should not cause any problems with prune command.
technoweenie commentedon Aug 18, 2016
Added to the roadmap in #1438.
Wingjam commentedon Apr 18, 2017
For now, how can we change
lfs.LocalMediaDir?damirdev commentedon May 4, 2018
Old question, but I'm also confused about configuration in shared directory (for build controllers). I was able to find solution only after research in source code in IDE.
In source code:
config.go
fs.go
Docs git-lfs-config.5.ronn
Notes aboute prune
Example (in global git config, windows):
Per project directory in bash (mingw)
ttaylorr commentedon May 4, 2018
Hi @dtulepov, these are all great references. I'm not quite sure about your specific question: are you having trouble configuring
lfs.storage, or is something not behaving as expected? Either way, I'd be more than happy to help, but I think that a new issue would be the best place to discuss.docs: reference related issues in shared cache proposal