Git submodules and orphaned commits

515 views Asked by At

I have a git repo (A) where each commit is an orphaned commit with a name (branch). Git repo B consumes A as a submodule, and as such is always holding a reference to a SHA in A. When I make a fresh clone of B I need to do the typical git submodule init/update incantation, but I don't want it to clone all of A. I just want it to clone the single orphaned commit which is the submodule reference.

However, even when I try git submodule update --init --recursive --depth 1 path/to/A, git clones from master instead. Is there a way I can convince it to clone only the SHA that I care about?

1

There are 1 answers

1
VonC On BEST ANSWER

If B consumes A as a submodule, it should do so by configuring A submodule to follow a branch.

That way, a git submodule update --init --recursive --remote --depth 1 path/to/A should checkout from the branch it is supposed to follow.