216

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

Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
Shubham Khatri
  • 270,417
  • 55
  • 406
  • 400

12 Answers12

338

In order to navigate to a different drive just use

cd /E/Study/Codes
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Jagrati
  • 11,474
  • 9
  • 35
  • 56
  • 20
    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 May 01 '17 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. – Yohan Hirimuthugoda Aug 12 '17 at 10:28
  • @Benvorth Can you please clarify your comment? (Case does not seem to matter for drive letters on Windows.) – skomisa Apr 30 '18 at 05:18
  • 3
    @skomisa if you use the `/mnt/...` notation mentioned by @ponir above the drive letter case was an issue for me... – Benvorth Apr 30 '18 at 09:48
  • 3
    When using this one (https://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. – JackGrinningCat Jan 16 '19 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 Jan 04 '20 at 11:28
  • 1
    @Chinmay Thanks, this works: `cd /D/SystemFolders/Downloads/crap` One has to put the forward-slash infront of the drive letter. – Legends Jan 07 '20 at 21:49
  • 1
    Running git bash on Windows 10, this solution did not work for me. An answer below suggested using `cd e:` instead, and that worked. – M - Jun 05 '20 at 19:36
  • 1
    @ponir's solution is the one that works perfectly. – Ahmad Feb 28 '21 at 11:54
50

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

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
17

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

Legends
  • 21,202
  • 16
  • 97
  • 123
15

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.

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
  • 12
    I tried this one but it did not work for me. It opens the window but close it immediately afterwards. – JackGrinningCat Jan 16 '19 at 15:01
  • 1
    Same as @JackGrinningCat for me. Did you change something in your setup for that to work Abdullah Khan ? – Martin Mar 10 '19 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. – Abdullah Khan Mar 10 '19 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 May 03 '19 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. – CarpeDiemKopi Jul 22 '19 at 14:28
  • 1
    Just Try this. $ cd /d/my_folder – JDGuide Feb 03 '21 at 13:02
10

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].

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Vyacheslav
  • 117
  • 1
  • 2
  • 9
8

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.

kendfss
  • 435
  • 5
  • 11
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).

Hannu
  • 263
  • 2
  • 14
6

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

cd /e/
desertnaut
  • 57,590
  • 26
  • 140
  • 166
5

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

Tanya Singh
  • 71
  • 1
  • 3
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
leighboz
  • 119
  • 7
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.

Sowik
  • 94
  • 6
0

To change from C drive to D drive in git bash

cd /D

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34864163) – Ram Chander Aug 25 '23 at 15:00