Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Git bash and WSL

I just installed Git SCM on my Windows machine. My machine had Node installed earlier. I am able to use node -v in git bash. But, Why I am able to use windows applications inside Git Bash and not in WSL Bash.

Inside WSL Bash-

hello@comp:~$ node -v

Command 'node' not found, but can be installed with:

sudo apt install nodejs

Inside Git Bash-

hello@comp MINGW64 
$ node -v
v12.10.0
like image 561
subhamX Avatar asked Sep 19 '19 17:09

subhamX


People also ask

Should I install git on Windows or WSL?

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 and Ubuntu the same?

Git bash is for git commands. Only commands of git work in the Git Bash. Ubuntu Bash is the complete script language for operating the system like the Windows Batch scripting but a bit advanced as we regularly use it in the Linux we focus for an easy to use the script language.

What is the difference between git and bash?

Git is a version control system that lets developers track source code changes during software development. Git Bash is an application for Microsoft Windows, allowing developers to use Git in a command-line interface.

Can I use git bash instead of Linux terminal?

You don't need to use Git Bash. It is just conventional, because Git was developed and designed on Linux and most Git users use Linux and using Git Bash on Windows makes it a uniform experience. You can certainly use Git on cmd; just make sure you add C:\Program Files\git\cmd to your PATH .


2 Answers

WSL is an a Linux like compatibility layer. You run Linux applications on top of WSL and they think they are running natively on Linux while the system calls are being translated to Windows OS system calls (WSL2 -- not yet released -- is a full Linux kernel running inside Windows). You do get to access Windows files through /mnt/c/... but that's about all you can expect in terms of Windows-Linux interoperability.

Git-bash, on the other hand, is a Windows app -- a shell running windows applications. Some of these may be compiled with a Linux compatibility library (Cygwin). But they don't have to be. This provides a less "Linux-like" experience but may be a good compromise if all you want are some Linux command line tools and don't need to install full-blown Linux executables.

like image 188
nimrodm Avatar answered Oct 01 '22 21:10

nimrodm


Definition of PATH for both "environments" is different. Check that node's dir shows up on Git bash's and not in WSL Bash. Run this on both environments:

echo $PATH
like image 36
eftshift0 Avatar answered Oct 01 '22 23:10

eftshift0