Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git bash on windows vs. WSL

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?

like image 716
Rhee Avatar asked Oct 20 '18 12:10

Rhee


People also ask

Should I install git on WSL or Windows?

It is recommended to install the latest Git for Windows in order to share credentials & settings between WSL and the Windows host. Git Credential Manager is included with Git for Windows and the latest version is included in each new Git for Windows release.

Is git Bash good for Windows?

Git Bash is a life saver for Windows users who want to leverage the power of the Git command line for their version control. It is easy to install Git Bash and start using it as stated throughout this article.

Is it better to use WSL or dual boot?

WSL vs Dual Booting Dual Booting means installing multiple operating systems on a single computer, and being able to choose which one to boot. This means that you CANNOT run both the OS at the same time. But if you use WSL, you can use both the OS simultaneously without the need to switch the OS.

Should I use WSL on Windows?

Why would I use WSL rather than Linux in a VM? WSL requires fewer resources (CPU, memory, and storage) than a full virtual machine. WSL also allows you to run Linux command-line tools and apps alongside your Windows command-line, desktop and store apps, and to access your Windows files from within Linux.


2 Answers

WSL does not trigger file handlers when the file is changed in Windows tools - https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/

So, you cannot run a dev server in WSL, as code changes made a Windows editor will not be reflected in the dev server.

like image 40
Colin Hobday Avatar answered Sep 20 '22 12:09

Colin Hobday


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" 
like image 83
VonC Avatar answered Sep 21 '22 12:09

VonC