gpt4 book ai didi

windows - 如何将 git 添加到 PATH(Windows 上的 Bash)

转载 作者:可可西里 更新时间:2023-11-01 14:48:11 32 4
gpt4 key购买 nike

我在 Windows 上的 Ubuntu 上使用 Bash,并且安装了 git。如何将 git 添加到我的 PATH 中?

最佳答案

一般命令是(using setx):

setx PATH=%PATH%;C:\path\to\Git\bin

在 WSL(适用于 Linux 的 Windows 子系统)上,您需要在安装后键入:

which git

它应该已经在您的PATH(/usr/bin/usr/local/bin)

如果不是,您可以尝试找到它:find/-name "git",并将其添加到您的 ~/.profile 中:

export PATH=$PATH:/path/to/git

但请注意,WSL 将安装旧版本的 Git。

对于最近的一个,使用:

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git-core

Where is /usr/local/bin on Windows?

BashOnWindows issue 402 中所述:

Under C:\Users\**user**\AppData\Local\lxss, You will find:

  • root folder
  • home folder
  • and a hidden rootfs folder (\bin, \boot, \dev, \etc...)

DON'T CHANGE ANYTHINK INSIDE! SERIOUSLY! 🚨

Access Windows files via /mnt/**letter**/

和:

Maybe I don't fully understand what Bash on Ubuntu on Windows is.

参见 Wikipedia WSL entry :

Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables (in ELF format) natively on Windows 10.
Windows Subsystem for Linux is only available on 64-bit editions of Windows 105 and can be activated on Windows 10 Anniversary Update and later.
WSL uses fewer resources than a full virtualized machine, the most direct way to run Linux software on a Windows computer, while also allowing users to use Windows apps and Linux tools on the same set of files.5

OP 添加:

So if I install git and it's in /usr/bin/git, does that correspond to a particular folder such as C:\Program Files\etc...?

是的,在 C:\Users\**user**\AppData\Local\lxss\rootfs\usr\... 下,但您不应该直接访问它。您只能通过 WSL bash 使用它。

Is setting my PATH different by putting it in my ~/.profile vs. going into Control Panel --> System Properties --> Environment Variables

是的,完全。如果你想设置 Windows 环境变量 PATH,你需要使用 Git for Windows , 作为 described in here .

关于windows - 如何将 git 添加到 PATH(Windows 上的 Bash),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44897059/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com