In the git submodule documentation for git submodule add
, it shows that there is a --reference
parameter. Presumably, this works the same way the --reference
parameter for git clone
works, by copying objects from it, instead of the remote repository. After executing with this parameter, if I look inside .git/modules/<submodule>/objects/info
, there is an alternates
file, containing the path to the reference repo.
However, git clone
also has a --dissociate
parameter, to essentially do this for only the initial clone. Is there a way to the same thing for a submodule repository?
Apparently the only way to do this is to run git repack -a -d
in the submodule directory after cloning it with --reference
.
I guess a future Git version might add direct support for --dissociate
to git submodule {add,update}
itself, but it doesn't exist in the latest (2.15) version yet.
" git submodule update
" and " git submodule add
" supported the " --reference
" option to borrow objects from a neighbouring local repository like " git clone
" does, but lacked the more recent invention " --dissociate
".
That is no longer the case with Git 2.18 (Q2 2018)
submodule: add
--dissociate
option to add/update commandsAdd
--dissociate
option to add and update commands, both clone helper commands that already have the--reference
option--dissociate
pairs with.
The documentation now adds:
--dissociate::
This option is only valid for
add
andupdate
commands.
These commands sometimes need to clone a remote repository. In this case, this option will be passed to thegit clone
command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.