通过IntelliJ在Windows子系统Linux中使用Git [英] Using Git in Windows Subsystem for Linux through IntelliJ

查看:2483
本文介绍了通过IntelliJ在Windows子系统Linux中使用Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将IntelliJ中的Git可执行文件设置为Windows子系统for Linux中安装的git,我尝试了几种不同的方法,但总是遇到某种错误。今天我安装了Creators Update(版本1703),重新安装了WSL并再次尝试,这就是我所做的:

I'm trying to set Git executable in IntelliJ to be the git installed in Windows Subsystem for Linux, I tried a few different ways, but always got some sort of error. Today I installed to Creators Update (Version 1703), reinstalled WSL and tried again, here's what I did:

我创建了一个.bat脚本:

I created a .bat script:

@echo off
C:\Windows\System32\bash.exe -c "git %*"

因此在运行时:

C:\Users\Limon\Desktop>bash.bat --version
git version 2.7.4

然后我尝试将这个bat设置为IntelliJ中的git可执行文件:

So then I tried to set this bat at the git executable in IntelliJ:

它有效!但其他一切都失败了,例如当我尝试在IntelliJ中拉或分支时,我得到:

And it worked! But everything else fails, for example when I try to pull or branch in IntelliJ, I get:

Couldn't check the working tree for unmerged files because of an error.
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command,
operable program or batch file.

有关如何解决此问题的任何想法?我对批处理脚本一无所知。它在命令行下完美运行。

Any ideas on how fix this? I don't really know anything about batch scripting. It works perfectly off command line.

推荐答案

我一直在寻找一种通过Webstorm在WSL Windows子系统Linux上使用git的方法一个IntelliJ想法软件。

I was looking for a way to use git on WSL Windows Subsystem for Linux through Webstorm or an IntelliJ idea software.

我尝试了KatoPue的解决方案,但是我收到了以下错误:

I tried KatoPue's solution, but I got the following error:

致命:无法读取日志文件'C:/ Program Files / Git / mnt / c / Users / Elies / AppData / Local / Temp / git-commit-msg-.txt':没有这样的文件或目录

我通过在将命令发送到WSL的git时替换路径来解决它

I solved it by replacing the path when sending the command to WSL's git

Settings > Version Control > Git > Path to Git executable : path_to_wslgit.bat

wslgit.bat:

wslgit.bat :

@echo off
setlocal enabledelayedexpansion
set command=%*
set find=C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt
set replace=/../../../Users/%USERNAME%/AppData/Local/Temp/git-commit-msg-.txt
call set command=%%command:!find!=!replace!%%
echo | bash.exe -c 'git %command%'

这篇关于通过IntelliJ在Windows子系统Linux中使用Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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