Dev*_*xon 37 git ssh github git-submodules
我正在尝试更新这个git repositary的子模块但是我一直遇到致命的错误:
[root@iptlock ProdigyView]# git submodule update --recursive
Cloning into core...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Clone of 'git@github.com:ProdigyView/ProdigyView-Core.git' into submodule path 'core' failed
Run Code Online (Sandbox Code Playgroud)
或者这样
[root@iptlock root]# git clone --recursive https://github.com/ProdigyView/ProdigyView.git
Cloning into ProdigyView...
remote: Counting objects: 438, done.
remote: Compressing objects: 100% (275/275), done.
remote: Total 438 (delta 172), reused 394 (delta 128)
Receiving objects: 100% (438/438), 8.03 MiB | 5.19 MiB/s, done.
Resolving deltas: 100% (172/172), done.
Submodule 'core' (git@github.com:ProdigyView/ProdigyView-Core.git) registered for path 'core'
Cloning into core...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Clone of 'git@github.com:ProdigyView/ProdigyView-Core.git' into submodule path 'core' failed
Run Code Online (Sandbox Code Playgroud)
有关为什么会发生子模块的任何想法?回购是这个:
https://github.com/ProdigyView/ProdigyView
(如果我不尝试将子模块克隆为子模块,则可以克隆子模块.)
Dan*_*ton 73
问题是git无法找到从服务器下载repo所需的公钥,解决方案是使用公共URL.
在.gitmodule文件中,您将找到以下条目:
[submodule "example"]
path = example
url = git@github.com:webhat/example.git
Run Code Online (Sandbox Code Playgroud)
需要将URL更改为模块的公共URL:
[submodule "example"]
path = example
url = https://github.com/webhat/example.git
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,前缀git @已更改为https://并且infix :变为/
编辑:
在您自己的存储库中,您可能需要使用git://而不是https://
之前的答案对我来说不清楚,所以我补充说.
编辑2:
如果您发现需要运行git submodule sync或需要编辑.git/config才能使其工作,您可能已经为子模块设置了遥控器.
小智 37
如果它可以帮助一些人:
我更新了我的.gitmodules
[submodule "example"]
path = example
url = https://github.com/webhat/example.git
Run Code Online (Sandbox Code Playgroud)
然后我也更新我的.git/config
[submodule "example"]
url = https://github.com/webhat/example.git
Run Code Online (Sandbox Code Playgroud)
就像你们之前说的那样(我感谢你).
然后我更新我的.git/modules/example/config
[remote "origin"]
fetch = [...]
url = https://github.com/webhat/example.git
Run Code Online (Sandbox Code Playgroud)
并完成我做
git submodule sync
git submodule init
git submodule update
Run Code Online (Sandbox Code Playgroud)
您可以在 jenkins 作业的 Build --> "Execute shell" 部分手动传入密钥:
ssh-agent bash -c 'ssh-add {path_to_private_key}; git submodule update --init --recursive'
例子:
ssh-agent bash -c 'ssh-add /var/lib/jenkins/.ssh/jenkins_rsa; git submodule update --init --recursive'
对于我来说,这种情况发生过很多次,我在 .bash_profile 中放置了一个函数(适用于 BSD sed / GNU / Mac):
\n\ngitfix () {\nif [ -f "./.gitmodules" ] ; then\n sed -E -i.bak -e "s/(url *= *)(.*:)(.*)/\\1https:\\/\\/github.com\\/\\3/g" .gitmodules \\\n git submodule sync\n git submodule update --init --recursive\nfi\n}\nRun Code Online (Sandbox Code Playgroud)\n\n一班轮:
\n\nsed -E -i.bak -e "s/(url *= *)(.*:)(.*)/\\1https:\\/\\/github.com\\/\\3/g" .gitmodules ; git submodule sync ; git submodule update --init --recursive\nRun Code Online (Sandbox Code Playgroud)\n\nvim 搜索/替换:
\n\n%s/\\(url\\s*=\\s*\\)\\(.*:\\)\\(.*\\)/\\1https:\\/\\/github.com\\/\\3/\nRun Code Online (Sandbox Code Playgroud)\n\n基于 Dani\xc3\xabl \ 的答案的底层解决方案
\nDev*_*xon -10
弄清楚了。.gitmodule 文件中的路径无法下载子模块。
| 归档时间: |
|
| 查看次数: |
49653 次 |
| 最近记录: |