从配置中的特定主机进行git-submodule更新 [英] Make git-submodule update from specific Host in config

查看:76
本文介绍了从配置中的特定主机进行git-submodule更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用本指南 #个人GitHub帐户托管github.com主机名github.com用户gitAddKeysToAgent是IdentityFile〜/.ssh/id_rsa#工作GitHub帐户托管github.com-work主机名github.com用户gitAddKeysToAgent是IdentityFile〜/.ssh/id_rsa_work

我已将工作ssh添加到我的工作git-repo中,我可以打电话给 git clone git@github.com-work:user/test.git 并将其克隆.

问题是 test 中有一个我无法更新的子模块,调用

  git子模块更新 

引发错误

 请确保您具有正确的访问权限并且该存储库存在.致命:将"git@github.com:user/Utils.git"克隆到子模块路径"C:/Users/user/Documents/work/test/Utils"失败 

似乎它尝试使用我的个人设置( git@github.com )而不是作品( git@github.com-work )拉动.我已将 git子模块init 调用,并尝试将 .gitmodule 网址修改为

  [子模块实用程序"]路径=实用程序网址= git@github.com-work:user/Utils.git 

我知道了:

调用 git子模块更新后,通过以下方式更改URL(尽管出于某些原因,它不会更改,尽管我更改了 .gitconfig 文件):

(假设您位于 test 文件夹中)

  git子模块set-url./Utils/git@github.com-work:user/Utils.git"git更新cd实用程序git checkout主 

Using this guide here I have created a work ssh-key (id_rsa_work) and changed my config file to

# Personal GitHub account
Host github.com
 HostName github.com
 User git
 AddKeysToAgent yes
 IdentityFile ~/.ssh/id_rsa

# Work GitHub account
Host github.com-work
 HostName github.com
 User git
 AddKeysToAgent yes
 IdentityFile ~/.ssh/id_rsa_work

I have added the work ssh to my work git-repo and I can call git clone git@github.com-work:user/test.git and clone it.

The problem is that there is a submodule in test which I cannot update, calling

git submodule update

throws the error


Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@github.com:user/Utils.git' into submodule path 'C:/Users/user/Documents/work/test/Utils' failed

It seems like it tries to pull using my personal setting (git@github.com) and not the work (git@github.com-work). I have called git submodule init and have tried modify the .gitmodule url to

[submodule "Utils"]
    path = Utils
    url = git@github.com-work:user/Utils.git

解决方案

I figured it out:

After calling git submodule update change the URL (for some reason it does not change, eventhough I change the .gitconfig file) by

(assume you are in the test folder)

git submodule set-url ./Utils/ "git@github.com-work:user/Utils.git"
git update
cd Utils
git checkout master

这篇关于从配置中的特定主机进行git-submodule更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆