Using Git in Windows Subsystem for Linux through IntelliJ

前端 未结 9 909
萌比男神i
萌比男神i 2021-01-30 11:10

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

相关标签:
9条回答
  • 2021-01-30 11:19

    As Gabrielizalo answered earlier, you need to use version 2020.2 and higher.

    • Go to Settings | Version Control | Git

    • Add \\wsl$\YOUR-WSL-VERSION\usr\bin\git to the Path to Git executable.

    Please note, if you are using the WLinux distribution, you need to use the name Pengwin. Even though the wsl -l command outputs the name as WLinux. Perhaps It will be fixed in future versions.

    This is how it works for me \\wsl$\Pengwin\usr\bin\git.

    0 讨论(0)
  • 2021-01-30 11:24

    In PyCharm 2018.1 I got various errors, when trying to settled up Git. I've to combine different approaches to make it run. Next code works for me:

    @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%'
    )
    

    UPD:

    Now is available integration with Git inside WSL through WSLGit wrapper. I've checket it out with PyCharm and it's work like a charm. Here is a link https://github.com/andy-5/wslgit

    0 讨论(0)
  • 2021-01-30 11:26

    Change the double to single quotes.

    You can log, what arguments are fed to your bat file

    @echo off
    @echo %*>> %~dp0log.txt
    bash.exe -c 'git %*'
    

    With that, i discovered i had some escaping problems.

    FYI: With the Win10 creators update piping bash and spawning it from Windows programs works fine.

    0 讨论(0)
  • 2021-01-30 11:31

    Since WebStorm 2020.2 EAP it is possible.

    Just add \\wsl$\YOUR-WSL-VERSION\usr\bin\git to the Path to Git executable:

    To get your WSL VERSION type in a console wsl -l

    0 讨论(0)
  • 2021-01-30 11:36

    In PhpStorm (2017.2 EAP) I get error

    Caused by: com.intellij.openapi.vcs.VcsException: 'bash.exe' is not recognized as an internal or external command, operable program or batch file.

    For solution i change last line to

    If %PROCESSOR_ARCHITECTURE% == x86 (
        C:\Windows\sysnative\bash.exe -c 'git %command%'
    ) Else (
        bash.exe -c 'git %command%'
    )
    
    0 讨论(0)
  • 2021-01-30 11:36

    For me this solution works:

    File: git.bat

    @echo off
    setlocal enabledelayedexpansion
    set command=%*
    If %PROCESSOR_ARCHITECTURE% == x86 (
        C:\Windows\sysnative\bash.exe -c 'git %command%'
    ) Else (
        bash.exe -c 'git %command%'
    )
    
    0 讨论(0)
提交回复
热议问题