git bash on windows vs. WSL

Rhee picture Rhee · Oct 20, 2018 · Viewed 15.9k times · Source

I downloaded git on my windows, and some other stuffs, including git bash, came along.

Although I didn't know why bash terminal has been included in the "git", it supported not only the functions for git, but other functions like mkdir, cp, mv, just like a real linux bash terminal.

Recently I came to know the WSL (Windows Subsystem for Linux), which makes bash terminal available in windows.

Is the git bash quite inferior to WSL in terms of functionality?

Does it contain some constraints that WSL doesn't have?

Answer

VonC picture VonC · Oct 21, 2018

Git for Windows is using the mingw-w64 project (as illustrated here) and msys2.
See more in "How are msys, msys2, and msysgit related to each other?".

That is vastly different from WSL, which emulates an actual Linux distribution.

Does it contain some constraints that WSL doesn't have?

The Git for Windows is based on a POSIX compatibility layer, which has limitations: POSIX support is deprecated since Windows 8.


Note: WSL will soon be replaced by WSL2, which uses an entirely new architecture that uses a real Linux kernel.


If your program depends on Git bash (and not WSL/WSL2 bash), make sure to put said Git for Windows first in your PATH, as Jon Skeet described in "USING “GIT BASH” FROM APPVEYOR", in an AppVeyor CI environment.

# Make sure we get the bash that comes with git, not WSL bash
  - ps: $env:Path = "C:\Program Files\Git\bin;$env:Path"