Reputation: 801
I need to automate the following step:
git clone A && cd A && (git clone B; git clone C)
I cannot use submodules. I cannot use a git wrapper (already existent or by writing some function in my *$shell_rc
).
Upvotes: 3
Views: 581
Reputation: 40655
I would simply add a script addExternals
to the top-dir of the repo, and mention it in the README
. You might consider adding a call of it to the build system, but I think it's best if you leave the control of the subrepositories to the user.
The reason why I believe that this is the best approach: You cannot influence your users before they have cloned the repository, and they need to be aware of the fact that you are relying on subrepositories which are not modules. If you just invoke some magic to get the subrepositories into place, your users will trip over it later when one of the subrepositories needs to be updated to make the main repo compile again.
Upvotes: 2
Reputation: 6992
You could use a post-checkout
hook. Thus, you could have your repositories B
and C
getting updated if user switches branches/refs in A
.
Upvotes: 1
Reputation: 1327754
You can use an alias
alias gitclones='git clone A && cd A && (git clone B; git clone C)'
Or you can define a custom wrapper (not git itself but a bash script in the user's path)
But the git way would be to use submodules, in which case a simple git clone --recursive --remote
would be enough.
You can make a submodule to follow a branch like master.
See "Git submodules: Specify a branch/tag"
Note that repo B and C will be consider as nested repo, only their gitlink will be recorded in A.
Upvotes: 2