Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git submodule with ssh key?

Tags:

git

github

I'm using main private repository from github. I added deploy key in settings on github and pulling by command:

GIT_SSH_COMMAND="ssh -i /root/.ssh/repo.key" git pull

Also I edit .git/config file:

[remote "origin"]
  url = [email protected]:username/reponame.git
  fetch = +refs/heads/*:refs/remotes/origin/*

And it works. But I also have a submodule (in private repo) and I want to pull it by ssh key like main repo. I tried to add new key to submodules repo and edit .git/config:

[submodule "misc/repo_sub"]
  url = [email protected]:username/repo_sub.git

GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git submodule update --remote misc/repo_sub

Also i tried:

cd misc/
GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git pull

But it does not work too.

So how can I update submodules from private github repo by key or how can i pull them by key?

like image 669
Quarind Avatar asked Aug 03 '26 02:08

Quarind


1 Answers

I found in .git/modules configs for submodules and changed https links to ssh.

After this command works ok:

GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git submodule update --remote misc/repo_sub
like image 200
Quarind Avatar answered Aug 05 '26 18:08

Quarind