2

Say I prefer the behavior of git in WSL to git.exe.

How do I make other applications that passes parameters to git.exe to actually use a the git instance in WSL?

The exe will be used by another application which relies on git.exe

I found a good starting point from Microsoft's article Run Linux tools from a Windows command line

C:\temp> wsl ls -la
<- contents of C:\temp ->

I am looking for something similar to alias

5
  • Make your own git.exe that passes the params to the one in the WSL instance? Commented Nov 5, 2020 at 19:16
  • @SeñorCMasMas yes. How does one do that? Commented Nov 5, 2020 at 19:16
  • I guess I could create some program in my programming language of choice but I have a feeling there's an easier way. Commented Nov 5, 2020 at 19:20
  • Something akin to ALIAS Commented Nov 5, 2020 at 19:21
  • 1
    I hope so for your sake.. I thought about it and there is probably not a way. I too thought of something like ALIAS.. but on the windows side, it's more complicated than that. Hopefully, some other brainiac will come along and prove me wrong. Commented Nov 5, 2020 at 19:22

1 Answer 1

2

One solution is to create a file named git.bat with the following contents.

@wsl git %*

This is a batch file (similar to a Unix shell script), which invokes wsl with the command you want to execute (git) passing to it via %* as arguments any arguments you passed to the batch file invocation.

Place the file somewhere in your path. Note that this approach will behave in unexpected ways with Unix and Windows quoting, absolute file paths, and arguments containing spaces. This stems from differences between the two environments and the (unwelcome) interactions between the Windows shell and the WSL environment.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .