VSCode作为Linux子系统上的Git编辑器(WSL)

问题描述 投票:2回答:1

Context

System Information (Windows)

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.17134 N/A Build 17134
...
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~3696 Mhz
BIOS Version:              American Megatrends Inc. 2.20, 10/27/2017

System Information (WSL)

OS: Debian
Kernel: x86_64 Linux 4.4.0-17134-Microsoft
Shell: zsh 5.3.1
CPU: Intel Core i7-8700K CPU @ 3.696GHz
RAM: 8041MiB / 16344MiB

Git

我在我的~/.gitconfig中有这个:

[core]
    editor = code --wait

Problem:

当我运行git commit时,vscode以C:\mnt\$PathToRepo$\.git\COMMIT_EDITMSG开头,但是这个文件是空的(它应该提交更改为+ diff)。

当我写一个提交消息,保存并退出时,我在终端中得到这个:

Aborting commit due to empty commit message.

注意:

当我这样做:

  1. 运行git commit;
  2. 在vscode中写入提交消息(例如:Initialize repo),保存并关闭;
  3. Aborting commit due to empty commit message.之后,我再次运行git commit;

VSCode将使用我在步骤2中写入的相同提交消息打开(即:初始化repo)

git visual-studio-code windows-subsystem-for-linux commit-message
1个回答
1
投票

如果重点是在vscode上使用WSL git,这里是官方解决方案:https://code.visualstudio.com/docs/remote/wsl

基本上,你只需要安装Remote Development Extension Pack


0
投票

在尝试更多的事情时,这个解决方案有效:https://github.com/Microsoft/vscode/issues/27101#issuecomment-306994732

整个问题是翻译Windows文件的位置。使用诸如链接到那里的脚本(https://github.com/Milly/wslpath)和包装脚本将允许消息在vscode中正确打开。我亲自删除了包装器脚本中的-n选项,因为我更喜欢使用选项卡。

© www.soinside.com 2019 - 2024. All rights reserved.