I have to automate cloning a repository and fetching it's all submodules. The urls for repository submodules are specified at .gitmodules
. If I were to go with defaults I would just do
git clone --recursive https://username:[email protected]
The problem is credentials aren't included in .gitmodules
file and I am prompted for those when I clone. I have to use HTTPS rather then SSH.
I tried to submit the credentials using git config:
git clone https://username:[email protected] my_repo
cd my_repo
git submodule init
git config submodule.my_submodule.url "https://username:password@url/my_submodule.git"
git submodule update
but I get prompted for credentials in the last update step. I've checked that the submodule url is correct and has proper credentials in .git/config
file.
After editting the .gitmodules
file you need to apply changes using
git submodule sync
The next time you run git submodule update
the new url will be used.
Looks like you are trying to use git credentials but not having any luck.
Option 1
Add credentials using the credential helper:
git config credential.https://example.com.username myusername
git config credential.helper "$helper $options"
Check your ~/.gitconfig and verify that the appropriate entry is added.
Further reading: http://git-scm.com/docs/gitcredentials
Option 2
I would double check the contents of your .git-credentials file and make a new entry for the submodule if it is not present. This file is used internally by the git credentials helper.
http://git-scm.com/docs/git-credential-store
Option 3
Easy solution in windows is to remove the username, password from modules file:
[submodule foo]
path = sub/foo
url = https://example.com/git/foo.git
And create a ~/.netrc file.
machine example.com
login myusername
password areamandyingtotellsomeonehiscoolpassword
Kudos to Git submodule URL not including username?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With