CutePoison
CutePoison

Reputation: 5365

Make git-submodule update from specific Host in config

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 [email protected]: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 '[email protected]: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 ([email protected]) and not the work ([email protected]). I have called git submodule init and have tried modify the .gitmodule url to

[submodule "Utils"]
    path = Utils
    url = [email protected]:user/Utils.git

Upvotes: 1

Views: 944

Answers (1)

CutePoison
CutePoison

Reputation: 5365

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/ "[email protected]:user/Utils.git"
git update
cd Utils
git checkout master

Upvotes: 1

Related Questions