简体   繁体   中英

Change drive in git bash for windows

I was trying to navigate to my drive location E:/Study/Codes in git bash in windows. In command prompt in order to change drive I use E: It returns an error in git bash .

bash: E:: command not found.

How do I change my current directory location from /c/users to E:Study/Codes

In order to navigate to a different drive just use

cd /E/Study/Codes

It will solve your problem.

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

TL;DR; for Windows users :

( Quotation marks not needed if path has no blank spaces )

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

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


When using git bash on windows, you have to:

  • remove the colon after the drive letter
  • replace your back-slashes with forward-slashes
  • If you have blank spaces in your path: Put quotation marks at beginning and end of the path

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

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

How I do it in Windows 10

Go to your folder directory you want to open in git bash like so

在此处输入图像描述

After you have reached the folder simply type git bash in the top navigation area like so and hit enter.

在此处输入图像描述

A git bash for the destined folder will open for you.

在此处输入图像描述

Hope that helps.

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

Another approach, which worked for me even though none of the above (didn't try the GUI approach, tbf) did. As per super user , try:

e:

That's it. No cd . works in gbash and windows cmd.

Now which drive letter did that removable device get?

Two ways to locate eg a USB-disk in git Bash :

$ 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)

... so; likely drive letter in this example => /e (or E:\ if you must), when knowing that C, G, and H are other things (in Windows).

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

cd c:/inetpub/wwwroot/blah

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

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

The way to do it on Windows 10 is cd /DF:\path

Do not forget to write \D in front of the path in order to change drives.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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