简体   繁体   English

如何使用Git for Windows更改Git Bash中的目录?

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

如何在Git Bash中更改目录C:/Users/myname/project name

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. 请注意ls / ,或键入cd /后跟Tab-completion,可能不会显示此文件夹的存在,但cd /c仍然有效。 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. 另请注意, pwd (用于打印当前工作目录)可能显示类似/bin ,但这可能不是git clone等命令的实际工作文件夹,它可能使用启动Git Bash的文件夹。

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. 如果您知道当前工作目录中有多少级别,则可以使用cd ../project/name来避免编写整个目录路径。

The .. represents moving 1 directory up. ..表示向上移动1个目录。

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 dir / x

If I remember correctly. 如果我没记错的话。 I do not have a windows machine. 我没有Windows机器。

It is a version of bash shell though, so you should be able to simply quote it. 它是bash shell的一个版本,所以你应该能够简单地引用它。 (And the dir /x may or may not work.) (并且dir /x可能有效也可能无效。)

An alternative that worked for me (Windows 10 x64) is putting the full address in quotes: 对我有用的替代方案(Windows 10 x64)将完整地址放在引号中:

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. 然后我就可以像mkdirtouch等那样成功地将它们放入Test for GitBash文件夹中。

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 但是您可以避免在项目文件和文件夹中使用空格,而是使用下划线

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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