Method 1: Force all git requests to HTTPS (Recommended, fastest)
If you don’t want to modify the configuration file manually, you can directly run this global configuration command. It tells Git: Whenever it encounters a git@github.com: address, it will automatically replace it with https://github.com/.
Run in the terminal:
Bash
git config --global url."https://github.com/".insteadOf git@github.com:
After running the above command, the update command to try again:
Bash
git submodule update --init --recursive
Note: If the sub-module is a private repo, Git will prompt for the GitHub username and password (the current password usually refers to a Personal Access Token). If it is a public repo, it will be downloaded directly.
Method 2: Manually modify the .gitmodules file
If you want to permanently modify the configuration of this project, you can edit the .gitmodules file in the root directory of the project.
- Edit the file:
Open .gitmodules using vim or nano:
Bash
vim .gitmodules
-
Modify the URL:
Find the section [submodule “policy”], and change the url from SSH format to HTTPS format.
Before modification:
Ini, TOML
url = git@github.com:shuosha/policy_training.gitModified:
Ini, TOML
url = https://github.com/shuosha/policy_training.git -
Synchronize and update (key step):
After modifying the file, you must run sync for Git to recognize the new URL, and then update it:
Bash
git submodule sync
git submodule update --init --recursive
Method 3: Only modify the local git configuration (does not affect files)
If you don’t want to modify the .gitmodules file in the code (to avoid affecting others when submitting), you can only modify the .git/config file.
-
Open the
.git/configfile:Bash
vim .git/config -
Find the
[submodule "policy"]section and replaceurlwithhttps://github.com/shuosha/policy_training.git. -
Save and exit, then run the update command directly.
Summary Recommendations
Since it is in the root@gpufree-container environment, I recommend using Method 1 directly. It does not require modifying files through an editor, and it can immediately solve similar issues of all submodules.
Next step:
You can directly copy and run this command, then try the update again:
Bash
git config --global url."https://github.com/".insteadOf git@github.com: && git submodule update --init --recursive