How do I change the directory in Git Bash with Git for Windows?

前端 未结 5 1828
醉梦人生
醉梦人生 2021-02-01 18:44

How would I change to the directory C:/Users/myname/project name in Git Bash?

相关标签:
5条回答
  • 2021-02-01 18:48
    cd /c/users/myname/project\ name
    

    Beware that ls /, or typing cd / followed by Tab-completion, might not show the existence of this folder, but cd /c will still work. Also note that pwd (to print the current working directory) might show something like /bin, but this might not be the actual working folder for commands such as git clone, which might use the folder from which Git Bash was started.

    0 讨论(0)
  • 2021-02-01 18:55

    If you are at the a directory and wanna switch to sub directory use :

    cd "project name"
    

    If you wanna go to a different path use the whole path :

    cd "C:/Users/myname/project name"
    

    But you can avoid use white spaces in project files and folders and instead use underscore

    0 讨论(0)
  • 2021-02-01 19:09

    If the you know how many levels up from your current working directory, you could use cd ../project/name to avoid writing the entire directory path.

    The .. represents moving 1 directory up.

    0 讨论(0)
  • 2021-02-01 19:11

    You will need to use quotes in your directory name, or the short version of the filename.

    You can find the short version of the file name by issuing the command:

    dir /x

    If I remember correctly. I do not have a windows machine.

    It is a version of bash shell though, so you should be able to simply quote it. (And the dir /x may or may not work.)

    0 讨论(0)
  • 2021-02-01 19:14

    An alternative that worked for me (Windows 10 x64) is putting the full address in quotes:

    cd "D:\BWayne\Documents\- School\Developer\-- Backend\Test for GitBash"
    

    I could then do like mkdir, touch, etc and it successfully put them in the Test for GitBash folder.

    0 讨论(0)
提交回复
热议问题