我有一个包含子模块的项目。使用不同的帐户通过ssh身份验证克隆项目和子模块。该项目的结构如下:
tests <- project root
|- tstsub <- submodule root
|- <project's files>
|- .gitmodules
这是我的~/.ssh/config
文件:
#activehacker account
Host github.com-matteoappfarmer
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_matteoappfarmer
ServerAliveInterval 60
#activehacker account
Host github.com-matteoappfarmer+gist
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_matteoappfarmer+gist
ServerAliveInterval 60
#activehacker account
Host github.com-bertamini.matteo
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_bertamini.matteo
ServerAliveInterval 60
这些是我用来设置项目的命令:
克隆我的项目
git clone git@github.com-bertamini.matteo:bertuz/bertuzFox.git tests
添加子模块(通过输入测试)
git submodule add git@github.com-bertamini.matteo:bertuz/bertuzFox.git tstsub
好的,让我们在新的.gitmodules中检查一切是否正常
[submodule "tstsub"]
path = tstsub
url = git@github.com-bertamini.matteo:bertuz/bertuzFox.git
github.com-bertamini.matteo
似乎是正确验证的正确选择。好的,让我们继续。
进入tstsub,创建并添加文件,提交它(记住我们现在在子模块中)。然后检查git是否正确设置了所有内容
MacBook-Pro-di-Matteo:tstsub matteo$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: README.md
好的!让我们试着推动我们的子模块:
MacBook-Pro-di-Matteo:tstsub matteo$ git push
ERROR: Permission to bertuz/bertuzFox.git denied to bertuz-gist.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
所以,似乎我们的子模块和多个ssh身份验证存在问题。它说&#34;延迟拒绝bertuz-gist&#34;。我认为git没有使用它应该使用的子模块的auth信息,而是项目的信息。为了推动我的子模块修改,我怎样才能正确更改和设置?