-
-
Save jmickela/7c383c78af66a37a2446fe7eb733b157 to your computer and use it in GitHub Desktop.
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. |
Thanks for sharing! If you add -i
flag for bash.exe
to make it read your .bashrc
file your .bashrc
file can hook up to ssh-agent automatically and thus read your SSH keys to avoid requiring password interaction. Here is what I use to "auto-connect" to the SSH agent:
# Automatically setup ssh agent if flag file exists
if ([[ $- == *i* ]] || [[ -n $CYGWIN_DIR ]]) && [[ -f ~/.ssh/.auto-agent ]]; then
# Allow cygwin to use PuTTY's pageant
if [[ -f /usr/bin/ssh-pageant ]]; then
eval $(/usr/bin/ssh-pageant -ra $TEMP/.ssh-pageant)
echo "Using PuTTY's Pageant"
# Use Linux ssh-agent and do not use Gnome Keyring
elif [[ -f /usr/bin/ssh-agent ]] && [[ $SSH_AUTH_SOCK != /tmp/ssh-* ]]; then
for agent in /tmp/ssh-*/agent.*; do
export SSH_AUTH_SOCK=$agent
ssh-add -l 2>&1 >/dev/null
if [[ $? -lt 2 ]]; then
echo "Using already running ssh-agent"
break
else
unset SSH_AUTH_SOCK
fi
done
if [ -z "$SSH_AUTH_SOCK" ]; then
eval $(ssh-agent)
echo "Starting new ssh-agent"
fi
fi
fi
For anyone still having problems with newest Windows (as of February 2018), the following has worked for me:
@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!%%
If %PROCESSOR_ARCHITECTURE% == x86 (
echo C:\Windows\sysnative\bash.exe -c 'git %command%'
) Else (
echo bash.exe -c 'git %command%'
)
source: this + StackOverflow
@oldamalec Just wanted to add that after the Creators/Anniversary update bash.exe is deprecated and instead it is suggested the use of wsl.exe
which doesn't need the -c
option to run a single command
Used this in IntelliJ IDEA, seems to work fine.
@echo off
setlocal enabledelayedexpansion
set command=%*
if exist "C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt" (
for /f "delims=" %%i in ('type C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt') do set commitmsg=!content! %%i
)
set find=-F C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt
set replace=-m "%commitmsg%"
call set command=%%command:!find!=!replace!%%
If %PROCESSOR_ARCHITECTURE% == x86 (
C:\Windows\Sysnative\bash.exe -c 'git %command%'
) Else (
C:\Windows\System32\bash -c 'git %command%'
)
Instead of letting it use a temp file, I read the commit file into a variable and then commit with "git -m "Commit Message""
@echo off
If %PROCESSOR_ARCHITECTURE% == x86 (
C:\Windows\sysnative\wsl.exe git %*
) Else (
wsl git %*
)
this will work :P
Used this in IntelliJ IDEA, seems to work fine.
@echo off setlocal enabledelayedexpansion set command=%* if exist "C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt" ( for /f "delims=" %%i in ('type C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt') do set commitmsg=!content! %%i ) set find=-F C:\Users\%USERNAME%\AppData\Local\Temp\git-commit-msg-.txt set replace=-m "%commitmsg%" call set command=%%command:!find!=!replace!%% If %PROCESSOR_ARCHITECTURE% == x86 ( C:\Windows\Sysnative\bash.exe -c 'git %command%' ) Else ( C:\Windows\System32\bash -c 'git %command%' )
Instead of letting it use a temp file, I read the commit file into a variable and then commit with "git -m "Commit Message""
cool
@echo off
If %PROCESSOR_ARCHITECTURE% == x86 (
C:\Windows\sysnative\wsl.exe git %*
) Else (
wsl git %*
)this will work :P
cool
@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
i found that the difference in line terminators when bash outputs on LF symbol Phpstorm wants to be CRLF there
i think replacing all LF to CRLF could help
upd: i tested it, and i was wrong, after replacing all LF to CRLF doesn't help, Phpstorm still doesn't get any effects
git.exe --version
and"bash.exe" -c "git --vesion" | FIND ""/V
give the same outputs but second doesnt work, dunno how its possible