有没有一种方法可以让VS Code在开发容器中使git正常工作? [英] Is there a way to get git to work properly from within a dev container using VS Code?

查看:78
本文介绍了有没有一种方法可以让VS Code在开发容器中使git正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VS Code ,并且安装了 Remote Development 扩展名.我为Angular应用程序创建了一个 devcontainer .到目前为止,一切正常. Dockerfile devcontainer.json 文件非常简单:

I am working with VS Code and I installed the Remote Development extension. I created a devcontainer for my Angular application. So far, everything works fine. The Dockerfile and the devcontainer.json files are pretty simple:

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" 属性的原因,并通过使用哪个git 命令在我的容器中.当然,所有git命令都不起作用,因为它们总是会导致错误.

Outside of my container, my git path is in the C:\Program Files\... directory. Within my container the git path is /usr/bin/git, which is why I set the "git.path" property up, and I verified this by using the which git command inside my container. Of course, none of the git commands work because they always lead to an error.

致命:无法chdir到'C:/Workspace/my-angular-app':没有这样的文件或目录

fatal: Could not chdir to 'C:/Workspace/my-angular-app': No such file or directory

我总是可以使用 Remote-Containers:Reopen Local 命令,一旦我回到Windows(容器外部),我的源代码控件就会点亮我所有的差异,而git可以正常工作美好的.但是,如果有一种方法可以使git在容器内工作,则将很有帮助.在进行更改时,我不想经常退出容器来识别差异.

I could always use the Remote-Containers: Reopen Locally command, and once I'm back in Windows (outside the container), my source control lights up with all my diffs and git works just fine. But, if there is a way to get git to work from within the container it would be helpful. I don't want to constantly have to exit the container to identify the diffs as I'm working on changes.

推荐答案

此问题已解决,但最初是Docker问题: https://github.com/microsoft/vscode-remote-release/issues/2591

This has been resolved, but it was originally a Docker issue: https://github.com/microsoft/vscode-remote-release/issues/2591

这篇关于有没有一种方法可以让VS Code在开发容器中使git正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆