Qua*_*oid 43 git github git-submodules travis-ci
我无法更新git子模块,错误如下:
$ git submodule init
Submodule 'build/html' (git@github.com: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.
Run Code Online (Sandbox Code Playgroud)
但是当我在本地执行相同的任务时,一切都很好.
我如何解决这个问题,以便Travis CI构建通过,我仍然可以单击repo中的子模块来指向它?
akn*_*ds1 72
这可以(幸运的是)通过在Travis上即时修改.gitmodules文件来轻松解决,以便在初始化子模块之前用公共URL替换SSH URL.要完成此操作,请将以下内容添加到.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/git@github.com:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
Run Code Online (Sandbox Code Playgroud)
感谢Michael Iedema的主旨,我从中得出了这个解决方案.
如果您的子模块是私有存储库,它应该在https URL中包含凭据,我建议为此目的制作具有受限权限的GitHub访问令牌:
# Replace <user> and <token> with your GitHub username and access token respectively
- sed -i 's/git@github.com:/https:\/\/<user>:<token>@github.com\//' .gitmodules
Run Code Online (Sandbox Code Playgroud)
您收到此错误是因为您通过ssh-urls指定了子模块.要从travis-ci环境进行ssh访问,您需要配置密钥.
或者,您可以使用git子模块的相对URL,因为您进行了项目,并且您的子模块在Github上都可用.
Git解决了相对的网址ORIGIN.
例:
使用您的前两个条目.gitmodules:
[submodule "lib/es5-shim"]
path = lib/es5-shim
url = git@github.com:kriskowal/es5-shim.git
[submodule "build/html"]
path = build/html
url = git@github.com:quadroid/clonejs.git
Run Code Online (Sandbox Code Playgroud)
替换为相对URL:
[submodule "lib/es5-shim"]
path = lib/es5-shim
url = ../../kriskowal/es5-shim.git
[submodule "build/html"]
path = build/html
url = ../clonejs.git
Run Code Online (Sandbox Code Playgroud)
然后当克隆 - 比如说 - 通过https时,原点设置如下:
$ git clone https://github.com/quadroid/clonejs.git
$ cd clonejs
$ git remote -v
origin https://github.com/quadroid/clonejs.git (fetch)
origin https://github.com/quadroid/clonejs.git (push)
Run Code Online (Sandbox Code Playgroud)
通过ssh克隆时:
$ git clone git@github.com:quadroid/clonejs.git
$ cd clonejs
$ git remote -v
origin git@github.com:quadroid/clonejs.git (fetch)
origin git@github.com:quadroid/clonejs.git (push)
Run Code Online (Sandbox Code Playgroud)
对于相对URL,通常的子模块序列独立于原点工作:
$ git submodule init
$ git submodule update
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12557 次 |
| 最近记录: |