Fail to clone submodules with Oauth token

Hi there,
I am trying to clone a bitbucket repository with submodules using OAuth token.
my .gitmodule file look like that:

[submodule "testmodule"]
	path = testmodule
	url = https://username@bitbucket.org/username/testmodule.git

I try to run the following command git clone --recurse-submodules https://x-token-auth:<TOKEN>@bitbucket.org/username/mainRepo.git
And I get the prompt
Password for 'https://username@bitbucket.org':
So the clone of the submodule fails.
I tried some workarounds like adding to the git config file

[url "https://x-token-auth:<TOKEN>@bitbucket.org"]
        insteadOf = https://username@bitbucket.org

Can someone suggest possible solution to clone submodules in the same git clone command?

1 Like