Search code examples
gitvscode-devcontainer

VSCode devcontainers: git permission denied when cloning a second repository inside the same devcontainer


Cloning a repository (let's call it "main repository") in dev container work fine.

Cloning another repository inside the same dev container does not work (permission denied).

Steps to reproduce:

  • In VSCode, "Clone repository in container volume" (from the menu). From there, everything work fine:

    • From the gui (pull, push)
    • From integrated terminal: "git pull", "git push" work fine
  • Opening a "integrated terminal" (running from inside the dev container), and try to clone another repository inside:

This is strange:

=> Why does the "main" repository work fine (with authorization), while another repository (where the credentials are the same) does not ?

Informations:

  • The devcontainer is a ubuntu:latest
  • Credentials are valid
  • I can "Clone repository in container volume" the secondary repository

Solution

  • In fact, VSCode containers use "https" to checkout from git.

    The solution is to use https://github.com/... to checkout the secondary repository.