Reputation: 121
Git is not detected when I open dev container in VisualStudio Code even when I cloned the file from GitHub using SSH key.
Docker Desktop is working fine, also Everything is working fine as I can perform build, clean and test.
I cannot commit changes because there is not git repository.
Local filesystem with cloned files:
I'm new to this. If anyone can help.
Upvotes: 12
Views: 9050
Reputation: 97118
I had this issue if your Git repo is actually a submodule, because git can't find the actual .git
directory (it isn't mounted in the Docker image).
If you go to Output->Git, you'll see a load of messages like
2023-09-19 10:18:14.820 [info] > git rev-parse --show-toplevel [1ms]
2023-09-19 10:18:14.820 [info] fatal: not a git repository: /workspaces/your_submodule/../../../.git/modules/path/to/your_submodule
I suspect there is no easy solution, other than cloning it separately.
Upvotes: 1
Reputation: 1329712
Developping inside a container means you need to Open a Git repository or GitHub PR in an isolated container volume#, in order for your container filesystem to mount the right local folder (the one with a .git
in it)
Start VS Code and run
Remote-Containers: Clone Repository in Container Volume...
from the Command Palette (F1).
Upvotes: 8