我试图将IntelliJ中的Git可执行文件设置为Windows Subsystem for Linux中安装的git,我尝试了几种不同的方法,但总是遇到某种错误。今天我安装了Creators Update (版本1703),重新安装了WSL,然后再试一次,下面是我所做的:
我创建了一个.bat脚本:
@echo off
C:\Windows\System32\bash.exe -c "git %*"
因此,在运行它时:
C:\Users\Limon\Desktop>bash.bat --version
git version 2.7.4
因此,我尝试在IntelliJ中的git可执行文件中设置此bat:
它成功了!但其他所有操作都失败了,例如,当我尝试在IntelliJ中拉入或分支时,我会得到:
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.
你有什么办法解决这个问题吗?我真的对批处理脚本一无所知。它可以在命令行之外完美地工作。
发布于 2017-05-10 03:45:38
我正在寻找一种通过Webstorm或IntelliJ idea软件在WSL Windows Subsystem for Linux上使用git的方法。
我尝试了KatoPue的解决方案,但得到了以下错误:
fatal: could not read log file 'C:/Program Files/Git/mnt/c/Users/Elies/AppData/Local/Temp/git-commit-msg-.txt': No such file or directory
我通过在将命令发送到WSL的git时替换路径解决了这个问题
Settings > Version Control > Git > Path to Git executable : path_to_wslgit.bat
wslgit.bat:
@echo off
setlocal enabledelayedexpansion
set command=%*
set find=C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt
set replace=/mnt/c/Users/%USERNAME%/AppData/Local/Temp/git-commit-msg-.txt
call set command=%%command:!find!=!replace!%%
echo | C:\Windows\Sysnative\bash.exe -c 'git %command%'
发布于 2018-04-28 05:04:12
在PyCharm 2018.1中,当我试图解决Git时,我得到了各种各样的错误。我必须结合不同的方法才能让它运行。下一个代码对我来说是有效的:
@echo off
setlocal enabledelayedexpansion
set command=%*
If %PROCESSOR_ARCHITECTURE% == x86 (
echo | C:\Windows\sysnative\bash.exe -c 'git %command%'
) Else (
echo | bash.exe -c 'git %command%'
)
更新:
现在可以通过WSLGit包装器在WSL中与Git集成。我已经用PyCharm验证过了,它工作得很棒。这是一个链接https://github.com/andy-5/wslgit
发布于 2017-04-28 17:20:06
将双引号更改为单引号。
您可以记录将哪些参数输入到bat文件中
@echo off
@echo %*>> %~dp0log.txt
bash.exe -c 'git %*'
有了这个,我发现我有一些逃脱的问题。
仅供参考:使用Win10创建者更新管道bash并从Windows程序中生成它可以很好地工作。
https://stackoverflow.com/questions/43666009
复制相似问题