I have a repository on an AWS instance. I can connect to the instance with VS Code via ssh and open the repository remotely. There is a dev container image on that instance that I use to run the code from a shell. I would like VS Code on my local machine to remotely open my repo on the instance, but inside a container spawned from my dev image. I have set up this .devcontainer.json
config file in the repo:
{
"image": "mmclassification",
"customizations": {
"vscode": {
"extensions": ["dbaeumer.vscode-eslint"]
}
},
"forwardPorts": [3000]
}
It seems to work fine. Before Remote-Containers, my Python extension couldn't follow imports etc. and now that works. However, git integration inside VS Code stopped working. Files don't get highlighted as modified anymore, and when I open the source control tab in VS Code, it says that it's not a git repository:
While the .git
folder does indeed exist, it's like VS Code can't read it.
Using only Remote-SSH to open the folder (i.e. not inside a container) does have working git integration (but Python integration is problematic because it's not opened in the dev environment).
What's the problem?
Here's a similar question: Git repository not detected inside a container created by VS Code Remote Container extension
However, the user there seems to have problems because of a worktree
directive in his .git/config
, which I don't have.
The solution is:
git config --global --add safe.directory <path/to/repo>
This was suggested by git after I ran git status
from inside a VS Code console.