1

I'm working on a project which uses AWS CodeCommit, and has 2 main apps, plus a submodule of shared components. On Windows I was able to clone all 3 repositories, and then I navigated into the sharedComponents directory in each of the main apps, and ran

git submodule update --init --recursive

This linked the shared components to the main app, and all was fine.

On Mac, however, I first had difficulty in cloning the repositories at all; eventually I got this working by setting up an ssh public private key pair (saved in ~/.ssh) and cloning that way. However, the git submodule command that I used above doesn't work in this scenario, and gives the error:

fatal: unable to access 'https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/MyRepoName/': The requested URL returned error: 403

which is the error I get when it can't access the security credentials.

So, I suspect that I need to tell git submodule update to use SSH mode, or to call the ssh version of the URL or something like that, but I'm not sure how to do this.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sharon
  • 3,471
  • 13
  • 60
  • 93
  • 2
    I've answered a similar question before. If both the main repo and its submodule are on the same server, you can use a relative URL. See https://stackoverflow.com/a/55242865/3216427 – joanis Dec 23 '21 at 14:03
  • 1
    In your case it's the other way around — ssh instead of https: `git config --global url.git@git-codecommit.eu-west-1.amazonaws.com:.insteadOf https://git-codecommit.eu-west-1.amazonaws.com/` – phd Dec 23 '21 at 14:04
  • 2
    @phd Personally I like the relative URL solution better, because I don't have to configure it in each sandbox. Using a relative URL means that however a developer has cloned the main repo, the other repos will be cloned using the same mechanism. When I move to a different server, too, I don't have to change anything in the submodule configuration. – joanis Dec 23 '21 at 14:05
  • 1
    Sorry, I linked the wrong question. My answer about using relative URLs is to this question: https://stackoverflow.com/a/68120599/3216427 . I think I need to have a better write up for the idea, though! – joanis Dec 23 '21 at 14:26
  • 1
    Thanks for the help. In my project root directory, I went into .git and modified config. I changed the Shared Components URL to ../MySharedComponents and that seems to have worked. – Sharon Dec 23 '21 at 14:58

0 Answers0