Last active
August 14, 2020 14:34
-
-
Save jmickela/7c383c78af66a37a2446fe7eb733b157 to your computer and use it in GitHub Desktop.
Trying to get PhpStorm to use git in Bash on Ubuntu on Windows (Windows Subsystem for Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There's a problem that you run into right away: you can't put a command line command, with arguments, | |
into the path to git executable box. | |
So putting something like bash.exe -c "git %*" isn't going to work. I wrote a small shell script that | |
fixes this, for both 32-bit and 64-bit systems. | |
@echo off | |
If %PROCESSOR_ARCHITECTURE% == x86 ( | |
"C:\Windows\sysnative\bash.exe" -c "git %*" | |
) Else ( | |
"bash.exe" -c "git %*" | |
) | |
If you set this script as the path to the git executable you'll get the correct git version back when | |
you hit the test button. You'll be able to use many of the local VCS functions, like viewing diffs or | |
previous commits. It should be noted that if you're on a 64 bit system you can't simply ignore the x86 | |
portion of the script, even if you run the 64 bit executable of PhpStorm, the VCS handling is 32 bit. | |
Or at least when this script is actually invoked it will fail if it can't run the 32 bit version. | |
Everything falls apart when you try to pull or push from a remote. If you watch the log the reason is | |
obvious: However the handling of private keys and/or passwords works, it doesn't work here. If you | |
cancel an attemp to fetch updates you'll get a few messages in the log about not being able to | |
authenticate with private key or password. | |
If I run my script in a windows command shell it works fine, it prompts me for a password and fetches | |
updates. For whatever reason that request for a password isn't making it into PhpStorm. | |
For now, I give up. Really, and I know it's unlikely, but I would like to see WSL supported because | |
there's a ton of tools in PhpStorm that assume you aren't doing something stupid like running a | |
different OS within your OS and trying to pipe all your commands into it while NOT doing this in a | |
VM where you could just run a SSH server. |
@echo off
If %PROCESSOR_ARCHITECTURE% == x86 (
C:\Windows\sysnative\wsl.exe git %*
) Else (
wsl git %*
)
This makes my IDE to hang
It works here. Save
@echo off
If %PROCESSOR_ARCHITECTURE% == x86 (
C:\Windows\sysnative\wsl.exe git %*
) Else (
wsl git %*
)
in wslgit.bat
and point phpstorm to it.
Used this snippet works for me 😂
@echo off If %PROCESSOR_ARCHITECTURE% == x86 ( C:\Windows\sysnative\wsl.exe git %* ) Else ( wsl git %* )
Thanks, works for me as well.
To fix different paths beetween windows and linux check out:
https://github.com/andy-5/wslgit
or
https://gist.github.com/KonradAdamczyk/adbdffbb8b535ccc1a7b2bd686128f5c
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool