3 ms·
Is there a git protocol variant that allows the client to avoid downloading objects that it already has stored locally in another repository or cache? For exam
by rwmj 9y ago
Is there a git protocol variant that allows the client to avoid downloading objects that it already has stored locally in another repository or cache?
For example: I have the Linux kernel already cloned in some directory. I clone a second repo which has the Linux kernel as a submodule. Can I clone the second repo straightforwardly without having to download Linux a second time? (Well yes, but only by manual intervention before doing the git submodule update - it'd be nice if objects could be shared in a cache across also repos somehow).
- andrewaylett 9y agoI'm assuming from your comment that you're already aware of --reference but it doesn't completely meet your needs? The only other thing I can think of would be to use the 'insteadOf' configuration to tell Git to use your local clone instead of the remote one. Search 'git help config' for 'url.<base>.insteadOf'.
- Boulth 9y agoHave you seen alternates? https://stackoverflow.com/questions/36123655/what-is-the-git-alternates-mechanism#36123844 https://stackoverflow.com/questions/36123655/what-is-the-git...
- nothrabannosir 9y agoYou could literally link the two object directories? I just tried this and it seems to work: git clone git://github.com/git/git mkdir git2 cd git2 git init cd .git/ rm -rf objects ln -s ../../git/.git cd ../ git remote add origin git://github.com/git/git git fetch # returned without downloading anything git checkout master ls # etc. If you seriously want to use this, you'll probably want to hard link the contents, instead. But iirc git clone from local disk already does that, for you? In short: clone your local copy and taking it from there?
- falsedan 9y agoYou can also use alternates: echo ../../../git/.git/objects >> git2/.git/objects/info/alternates or use the original as a reference: git clone --reference git git://github.com/git/git git2 This sets up the alternates for you.
- deleted 9y ago[deleted]
- Bjartr 9y agoMaybe this project could work for you? https://github.com/jonasmalacofilho/git-cache-http-server https://github.com/jonasmalacofilho/git-cache-http-server
- wereHamster 9y agoThere's git command for that: https://git-scm.com/docs/git-worktree https://git-scm.com/docs/git-worktree