I cannot update the git submodule, with the error:
$ git submodule init Submodule 'build/html' ([email protected]:quadroid/clonejs.git) registered for path 'build/html' ... $ git submodule update Cloning into 'build/html'... Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository.
But when I do the same tasks locally, everything is OK.
How do I fix this so that the Travis CI build passes and I can still click on the submodule in the repo to direct to it?
Always use the "git" user$ ssh -T [email protected] > Permission denied (publickey). If your connection failed and you're using a remote URL with your GitHub username, you can change the remote URL to use the "git" user. You should verify your connection by typing: $ ssh -T [email protected] > Hi username!
GitHub's Permission denied (publickey) error is usually caused by one of the following three issues: You have used an incorrect email address in the GitHub SSH URL. You have not configured your public SSH key in your GitHub account. You must create GitHub SSH keys to be used by the secure shell.
The “Permission denied (publickey). fatal: Could not read from remote repository” error is caused by an issue with the way in which you authenticate with a Git repository. To solve this error, make sure your key is being used on your Git account. If it is not, add your key to Git.
This can (thankfully) be easily solved by modifying the .gitmodules file on-the-fly on Travis, so that the SSH URL is replaced with the public URL, before initializing submodules. To accomplish this, add the following to .travis.yml:
# Handle git submodules yourself git: submodules: false # Use sed to replace the SSH URL with the public URL, then initialize submodules before_install: - sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules - git submodule update --init --recursive
Thanks to Michael Iedema for his gist from which I derived this solution.
If your submodules are private repositories, it should work to include credentials in the https URLs, I recommend making a GitHub access token with restricted permissions for this purpose:
# Replace <user> and <token> with your GitHub username and access token respectively - sed -i 's/[email protected]:/https:\/\/<user>:<token>@github.com\//' .gitmodules
I'd recommend using the https
scheme for submodules, as that'll allow you to pull on Travis and push locally: https://github.com/quadroid/clonejs.git
.
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