1

GitBash is one of the options one has to operate a Bash environment directly inside Windows. However, there now is the option to use the Windows Linux Subsystem (WLS), that can be launched from the classical terminal (cmd) by entering the command bash. However, despite both WLS and GitBash existing on the same Windows instance and environment, I don't yet see a direct way of launching the more powerful WLS environment from a GitBash shell.

Definitely, there would be the option of launching cmd inside GitBash, and then attempting to launch WLS by entering bash next, however, testing on Windows 10, I find that doing this has that bash command launch a new GitBash shell from the classical terminal shell instead. How to launch WLS instead?

NOTE: "Windows Linux Subsystem" == "Windows Subsystem for Linux" in this case. I just prefer to use the former.

2
  • Your apparent preference for "WLS" as a term for the Windows Subsystem for Linux, which is what everybody else calls it, may have blinded you to the wsl command now used to run wsl.exe, which you may wish to try. Commented Oct 20, 2020 at 11:34
  • Sure. I found that an example invocation such as wsl -e "cal" works, however running wsl on its own doesn't -- seems to just hang -- that is when invoking WSL from GitBash. If on classic CMD instead, all works fine. Thanks!
    – JWL
    Commented Oct 21, 2020 at 10:13

2 Answers 2

3

The correct answer is to use, in gitbash:

winpty wsl
3
  • Would you care to edit and expand upon your answer and format it correctly? Commented Jul 2, 2022 at 8:20
  • The question was how to start a wsl shell from a gitbash terminal as I understand it. Commented Jul 3, 2022 at 13:56
  • There is another way to do that: Newer versions of gitbash have now a way to add support for pseudoterminals. I had to uninstall my gitbash and reinstall it fresh. When looking at the options check the pseudoterminal on. Once done you can just type wsl in the terminal and it will show the wsl prompt from the os Commented Jul 3, 2022 at 13:58
1

A simple "wsl" command works for me, to go from git bash to wsl shell. I'm on git bash v 2.30, and WSL Ubuntu 20.04.

(see screenshot)

screenshot

2
  • Does not work for me, although I have newest software installed Commented Jul 2, 2022 at 6:46
  • 1
    requires installation of gitbash with pseudoterminal Commented Jul 3, 2022 at 14:02

You must log in to answer this question.

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