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 in
I updated the soultion to work with WSL2 with a network drive and PhpStorm 2019.2.
wsl_git.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 | wsl CURDIR="%cd%"; STR2=${CURDIR//\\//}; STR3=${STR2/U:/}; cd $STR3; git %command%
It replaces the path in command
for git-commit-msg-.txt
to be able to commit as it was mentioned in other answers.
With WSL2 I use the network drive: \\wsl$\
-> U:\
. My project has path on Windows: U:\home\roman\projects\experiments
, but on Linux it is /home/roman/projects/experiments
. PhpStorm uses path from Windows to work with git, so it is needed to change path which can be reachable in the Linux subsystem. To achieve this I replace slashes \
-> /
(STR2
) and remove drive name U:
-> `` (STR3
) then change current dir to this modified path.