有没有办法让 git 使用 VS Code 从开发容器中正常工作?
Is there a way to get git to work properly from within a dev container using VS Code?
我正在使用 VS Code
并安装了 Remote Development
扩展。我为我的 Angular 应用程序创建了一个 devcontainer
。到目前为止,一切正常。 Dockerfile 和 devcontainer.json 文件非常简单:
Dockerfile:
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12
devcontainer.json:
{
"name": "Angular App",
"dockerFile": "Dockerfile",
"settings": {
"git.path": "/usr/bin/git",
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"angular.ng-template",
"natewallace.angular2-inline",
"dbaeumer.vscode-eslint"
],
"forwardPorts": [4200, 9876],
"mounts": [ ],
"remoteEnv": { },
"postCreateCommand": "yarn install",
}
在我的容器之外,我的 git 路径在 C:\Program Files\... 目录中。在我的容器中,git 路径是 /usr/bin/git,这就是我设置 "git.path"
属性 的原因,我通过在我的容器中使用 which git
命令。当然,git 命令中的 none 有效,因为它们总是会导致错误。
fatal: Could not chdir to 'C:/Workspace/my-angular-app': No such file
or directory
我总是可以使用 Remote-Containers: Reopen Locally
命令,一旦我回到 Windows(在容器外),我的源代码控制就会亮起所有差异和 git工作得很好。但是,如果有一种方法可以让 git 在容器内工作,那将会很有帮助。我不想在处理更改时不断退出容器以识别差异。
您可能还需要将 Windows 样式路径更改为 *nix 样式路径。在这种情况下,而不是 C:/Workspace.... 尝试 /mnt/c/Workspace...
这已经解决,但最初是 Docker 问题:https://github.com/microsoft/vscode-remote-release/issues/2591
我正在使用 VS Code
并安装了 Remote Development
扩展。我为我的 Angular 应用程序创建了一个 devcontainer
。到目前为止,一切正常。 Dockerfile 和 devcontainer.json 文件非常简单:
Dockerfile:
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12
devcontainer.json:
{
"name": "Angular App",
"dockerFile": "Dockerfile",
"settings": {
"git.path": "/usr/bin/git",
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"angular.ng-template",
"natewallace.angular2-inline",
"dbaeumer.vscode-eslint"
],
"forwardPorts": [4200, 9876],
"mounts": [ ],
"remoteEnv": { },
"postCreateCommand": "yarn install",
}
在我的容器之外,我的 git 路径在 C:\Program Files\... 目录中。在我的容器中,git 路径是 /usr/bin/git,这就是我设置 "git.path"
属性 的原因,我通过在我的容器中使用 which git
命令。当然,git 命令中的 none 有效,因为它们总是会导致错误。
fatal: Could not chdir to 'C:/Workspace/my-angular-app': No such file or directory
我总是可以使用 Remote-Containers: Reopen Locally
命令,一旦我回到 Windows(在容器外),我的源代码控制就会亮起所有差异和 git工作得很好。但是,如果有一种方法可以让 git 在容器内工作,那将会很有帮助。我不想在处理更改时不断退出容器以识别差异。
您可能还需要将 Windows 样式路径更改为 *nix 样式路径。在这种情况下,而不是 C:/Workspace.... 尝试 /mnt/c/Workspace...
这已经解决,但最初是 Docker 问题:https://github.com/microsoft/vscode-remote-release/issues/2591