Change drive in git bash for windows
Asked Answered
C

12

230

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

Champlain answered 25/7, 2016 at 9:13 Comment(0)
C
350

In order to navigate to a different drive just use

cd /E/Study/Codes
Chadchadabe answered 25/7, 2016 at 9:15 Comment(9)
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.Harborage
@Harborage I think method is still same as Jagrati define. It worked for Git 2.14.1 64 bit version recent release as well.Patch
@Benvorth Can you please clarify your comment? (Case does not seem to matter for drive letters on Windows.)Kamakura
@Kamakura if you use the /mnt/... notation mentioned by @Harborage above the drive letter case was an issue for me...Stator
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.Fasciculus
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 .Molal
@Molal Thanks, this works: cd /D/SystemFolders/Downloads/crap One has to put the forward-slash infront of the drive letter.Eradicate
Running git bash on Windows 10, this solution did not work for me. An answer below suggested using cd e: instead, and that worked.Augusto
@ponir's solution is the one that works perfectly.Postmark
E
54

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

Escalator answered 21/11, 2018 at 9:49 Comment(2)
@Choco Thanks!. I am happy I could help. And yet I got downvoted some days ago :/Escalator
Didn't downvote, but for some reason, cd e: works but the autocomplete doesn't. It only autocompletes if I use cd /e/.Bye
E
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

Eradicate answered 7/1, 2020 at 22:1 Comment(0)
P
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.

Popular answered 21/11, 2018 at 10:13 Comment(6)
I tried this one but it did not work for me. It opens the window but close it immediately afterwards.Fasciculus
Same as @Fasciculus for me. Did you change something in your setup for that to work Abdullah Khan ?Grenier
No i simply installed the git. The installation gave me git bash and git cmd. And this solution works great for me.Popular
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.Lapidify
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.Lightish
Just Try this. $ cd /d/my_folderKingdon
G
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].

Gonagle answered 5/4, 2018 at 14:53 Comment(1)
This worked for my network drive; apparently G: is actually //tsclient/GSteading
T
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.

Terriss answered 7/7, 2021 at 1:22 Comment(0)
B
7

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

cd /e/
Bulge answered 1/4, 2022 at 4:9 Comment(0)
M
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).

Marriageable answered 10/6, 2020 at 6:29 Comment(0)
G
5

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

Gateshead answered 2/12, 2021 at 4:23 Comment(0)
H
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
Hoffman answered 19/11, 2021 at 15:17 Comment(0)
P
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.

Provinciality answered 19/6, 2022 at 13:55 Comment(0)
H
0

To change from C drive to D drive in git bash

cd /D

Heidyheifer answered 18/8, 2023 at 19:10 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewNobe

© 2022 - 2024 — McMap. All rights reserved.