繁体   English   中英

Git bash和WSL有什么区别

[英]What's the difference between Git bash and WSL

我刚刚在我的 Windows 机器上安装了 Git SCM。 我的机器之前安装了 Node。 我可以在 git bash 中使用 node -v。 但是,为什么我能够在 Git Bash 中使用 windows 应用程序而不是在 WSL Z7024FF03F70DEC6DAB1779A 中。

WSL Bash 内部

hello@comp:~$ node -v

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

sudo apt install nodejs

内部 Git Bash-

hello@comp MINGW64 
$ node -v
v12.10.0

WSL 是一个类似于 Linux 的兼容层。 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). 您确实可以通过 /mnt/c/... 访问 Windows 文件,但就 Windows-Linux 互操作性而言,这就是您所能期望的。

另一方面,Git-bash 是一个Windows应用程序——一个运行 windows 应用程序的 shell。 其中一些可以使用 Linux 兼容(Cygwin) 编译。 但他们不必如此。 这提供了一种不太“类似 Linux”的体验,但如果您只需要一些 Linux 命令行工具并且不需要安装成熟的 Linux 可执行文件,这可能是一个很好的折衷方案。

两种“环境”的 PATH 定义是不同的。 检查节点的目录是否显示在 Git bash 上,而不是 WSL Bash 中。 在两个环境中运行它:

echo $PATH

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM