Git submodules update

Hi!
I have git repo on GitLab.
This repo has git submodule “common”.
I want install this submodule on app deployment.
I added new hook:

cd {{ releasePath }}
git submodule update --init --recursive

after default Copy Project hook.

Have next error:

git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Could anybody help with this?

Maybe I can change default hook “Copy Project” somehow to add --recurse-submodules flag to git clone command?

Thank you in advance :slight_smile:

Hello @LostDok,

Could you please try updating your command with the command below and let us know if it works in this case

git submodule update --init --recursive https://{{ username }}:{{ token }}@github.com/{{ username }}/{{ repo }}.git

In this command:

  • {{ username }} represents your GitHub username.
  • {{ token }} represents your personal access token associated with your GitHub account, which can be generated from Sign in to GitHub · GitHub page.
  • {{ repo }} denotes the name of the repository you’re attempting to deploy.

Be sure to replace these placeholders with the appropriate values.

Thank you, Anish.

I tried to do as you recommend.

I used this template:

https://{username}:{token}@gitlab.com/{group}/{repo}.git

I got an error:

Init submodules 20240416124048727
error: pathspec 'https://{username}:{token}@gitlab.com/{group}/{repo}.git' did not match any file(s) known to git
  1. I use GitLab, not GitHub.
  2. My repo is in the separate group on GitLab, so I used gitlab.com/{group}/{repo}.git.

Do you have any ideas what else could I do?

Hello @LostDok,

In case of GitLab please use the following command:

git submodule update --init --recursive {{ branch }} --single-branch https://oauth2:{{ token }}@gitlab.com/{{ repository }}