234

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

0

12 Answers 12

353

In order to navigate to a different drive just use

cd /E/Study/Codes
9
  • 21
    I think the method has changed. The method in this answer didn't work. I had to use, cd /mnt/e/Study/Codes to navigate to that folder.
    – ponir
    Commented May 1, 2017 at 11:28
  • 7
    @ponir I think method is still same as Jagrati define. It worked for Git 2.14.1 64 bit version recent release as well. Commented Aug 12, 2017 at 10:28
  • 3
    @skomisa if you use the /mnt/... notation mentioned by @ponir above the drive letter case was an issue for me...
    – Benvorth
    Commented Apr 30, 2018 at 9:48
  • 3
    When using this one (git-scm.com/download/win) only cd /C/ worked for me, cd /mnt/C/ or cd /mnt/c/ does not work for me. Has to be something special. Commented Jan 16, 2019 at 14:57
  • 4
    I agree with answer from Jagrati. Do a quick check with 'pwd'. I the current working directory is shown as something starting with /c/.. then use /e/Sudy/Codes to access E: drive. If the result of 'pwd' shows something starting with /mnt/c/... then to access the E: drive you need to use /mnt/e/Study/Codes .
    – Chinmay
    Commented Jan 4, 2020 at 11:28
56

Just consider your drive as a folder so do cd e:

3
  • 1
    @Choco Thanks!. I am happy I could help. And yet I got downvoted some days ago :/ Commented Jun 10, 2019 at 0:48
  • 2
    Didn't downvote, but for some reason, cd e: works but the autocomplete doesn't. It only autocompletes if I use cd /e/. Commented May 5, 2020 at 2:57
  • 1
    Still loving this answer (cause it helped me) 5 years later. Commented Jul 17 at 23:12
20

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

16

How I do it in Windows 10

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

enter image description here

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

enter image description here

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

enter image description here

Hope that helps.

6
  • 12
    I tried this one but it did not work for me. It opens the window but close it immediately afterwards. Commented Jan 16, 2019 at 15:01
  • 1
    Same as @JackGrinningCat for me. Did you change something in your setup for that to work Abdullah Khan ?
    – Martin
    Commented Mar 10, 2019 at 16:04
  • 1
    No i simply installed the git. The installation gave me git bash and git cmd. And this solution works great for me. Commented Mar 10, 2019 at 16:15
  • 4
    This worked for me, but I skipped the git part and just did bash. Also, my /C: directory is /mnt for some reason. No idea why. Regarding the above questions, I have the linux box for windows 10+ enabled. You might be seeing that crashing on bash command if you haven't enabled bash.
    – Forrest
    Commented May 3, 2019 at 16:13
  • 2
    This is the best answer for my case: Only bash works for me! Windows 10 1803 windows-subsystem for linux (WSL) with Ubuntu 18.04 LTS. Commented Jul 22, 2019 at 14:28
9

In order to navigate to a different drive/directory you can do it in convenient way (instead of typing cd /e/Study/Codes), just type in cd[Space], and drag-and-drop your directory Codes with your mouse to git bash, hit [Enter].

1
  • 3
    This worked for my network drive; apparently G: is actually //tsclient/G
    – Neal Fultz
    Commented Jan 23, 2019 at 17:29
9

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.

0
8

I tried various forms, and finally, This worked for me:

cd /e/
6

Now which drive letter did that removable device get?

Two ways to locate e.g. 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).

5

Just write cd E:Study/Codes and it'll work.

3

I'm not sure why but in my git bash I had to include the colon for the drive letter

cd c:/inetpub/wwwroot/blah
2

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

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

0

To change from C drive to D drive in git bash

cd /D

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.