2

I'm trying to setup a git repository with some submodules. However, whenever I try to do a recursive clone of the repository, it keeps trying to use my local username regardless of the username that I specified on the original git clone command.

Here is the original command I ran

git clone --recursive  ssh://{user id}@{ip address}/app/data/git/repo.git

The clone of the original repo works fine and uses the user id specified in the ssh line. However, when it gets to the submodules it uses my local account instead of the user id specified in the ssh request.

This is what my .gitmodules file looks like

[submodule "modules/submodule"]
        path = modules/submodule
        url = ssh://{ip address}/app/data/git/submodule.git

Is there some system environment setting or something in the gitmodule file that needs to be set? This needs to work for multiple user accounts, so I can't just hardcode my userid into the .gitmodule file.

Thanks.

Shayan
  • 568
  • 1
  • 5
  • 7

2 Answers2

0

Can you do something like this? I don't know if it works for sure, but worth a shot.

https://stackoverflow.com/a/10056098/237091 see Choosing between multiple accounts at GitHub (or Heroku or...)

Community
  • 1
  • 1
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
0

The solution lies in updating your ssh-agent with the following entry. For mac/linux users,

  1. Open ssh config by typing in terminal "vim ~/.ssh/config"
  2. Add the following entry,
    # Github account
    Host github.com
        HostName github.com <- your git repository url
        User newUserName  <-- ensure this is the user name you want to use for submodules
        IdentityFile ~/.ssh/id_rsa <- if you have a different name then change this

Post this change, you should be able to clone submodules correctly as well.

milan pandya
  • 147
  • 1
  • 10