繁体   English   中英

在 Windows 的 git bash 中更改驱动器

[英]Change drive in git bash for windows

我试图在 Windows 的git bash中导航到我的驱动器位置E:/Study/Codes 在命令提示符中为了更改驱动器,我使用E:它在git bash中返回错误。

bash: E:: 找不到命令。

如何将当前目录位置从/c/users更改为E:Study/Codes

为了导航到不同的驱动器,只需使用

cd /E/Study/Codes

它会解决你的问题。

只需将您的驱动器视为一个文件夹, cd e:

TL;博士; 对于 Windows 用户

如果路径没有空格,则不需要引号

Git Bash : cd "/C/Program Files (x86)/Android" // macOS/Linux syntax

Cmd.exe : cd "C:\Program Files (x86)\Android" // windows syntax


在 Windows 上使用git bash时,您必须:

  • 删除驱动器号后的冒号
  • 用正斜杠替换你的反斜杠
  • 如果路径中有空格:在路径的开头和结尾加上引号

Git Bash : cd "/C/Program Files (x86)/Android" // macOS/Linux syntax

Cmd.exe : cd "C:\Program Files (x86)\Android" // windows syntax

我如何在 Windows 10 中做到这一点

像这样转到要在 git bash 中打开的文件夹目录

在此处输入图像描述

到达文件夹后,只需在顶部导航区域中键入git bash ,然后按 Enter。

在此处输入图像描述

一个用于指定文件夹的 git bash 将为您打开。

在此处输入图像描述

希望有帮助。

为了导航到不同的驱动器/目录,您可以以方便的方式进行(而不是输入 cd /e/Study/Codes),只需输入 cd[Space],然后用鼠标拖放目录 Codes要 git bash,请按 [Enter]。

另一种方法对我有用,即使上述方法都没有(没有尝试 GUI 方法,tbf)。 根据超级用户,尝试:

e:

而已。 没有cd 适用于 gbash 和 windows cmd。

现在该可移动设备获得了哪个驱动器号?

git Bash中找到例如 USB 磁盘的两种方法:

$ cat /proc/partitions
    major minor  #blocks  name   win-mounts

        8     0 500107608 sda
        8     1   1048576 sda1
        8     2    131072 sda2
        8     3 496305152 sda3   C:\
        8     4   1048576 sda4
        8     5   1572864 sda5
        8    16         0 sdb
        8    32         0 sdc
        8    48         0 sdd
        8    64         0 sde
        8    80   3952639 sdf
        8    81   3950592 sdf1   E:\

    $ mount
    C:/Program Files/Git on / type ntfs (binary,noacl,auto)
    C:/Program Files/Git/usr/bin on /bin type ntfs (binary,noacl,auto)
    C:/Users/se2982/AppData/Local/Temp on /tmp type ntfs (binary,noacl,posix=0,usertemp)
    C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)
    E: on /e type vfat (binary,noacl,posix=0,user,noumount,auto)
    G: on /g type ntfs (binary,noacl,posix=0,user,noumount,auto)
    H: on /h type ntfs (binary,noacl,posix=0,user,noumount,auto)

... 所以; 当知道 C、G 和 H 是其他东西(在 Windows 中)时,此示例中可能的驱动器号 => /e (或 E:\,如果必须的话)。

我不知道为什么,但在我的 git bash 中,我必须包含驱动器号的冒号

cd c:/inetpub/wwwroot/blah

只需编写cd E:Study/Codes即可。

我尝试了各种形式,最后,这对我有用:cd /e/

在 Windows 10 上执行此操作的方法是cd /DF:\path

不要忘记在路径前写\D以更改驱动器。

暂无
暂无

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

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