Git Bash 无法将目录更改为文档文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33626377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:41:20  来源:igfitidea点击:

Git Bash can't change directory to documents folder

git

提问by Natey17

I'm trying to following this Github tutorial: https://www.youtube.com/watch?v=73I5dRucCdsWhen I try to change my directory to my desktop, I get this in my Git Shell:

我正在尝试遵循此 Github 教程:https: //www.youtube.com/watch?v=73I5dRucCds 当我尝试将目录更改为桌面时,我在 Git Shell 中得到了这个:

Natha_000@idea-PC MINGW64 ~ 
$ cd /desktop
bash: cd: /desktop: No such file or directory

Natha_000@idea-PC MINGW64 ~
$ cd /Desktop
bash: cd: /Desktop: No such file or directory

Natha_000@idea-PC MINGW64 ~
$ cd Desktop
bash: cd: Desktop: No such file or directory

Natha_000@idea-PC MINGW64 ~
$ cd Documents
bash: cd: Documents: No such file or directory

Natha_000@idea-PC MINGW64 ~
$ cd /c/Desktop
bash: cd: /c/Desktop: No such file or directory

Natha_000@idea-PC MINGW64 ~
$ cd Documents
bash: cd: Documents: No such file or directory

I've tried a few different things and It doesn't seem to work. Any ideas about what I'm doing wrong? I'm guessing it's going to be a pretty stupid mistake...

我尝试了一些不同的东西,但似乎不起作用。关于我做错了什么的任何想法?我猜这将是一个非常愚蠢的错误......

回答by Alberto Zaccagni

It seems to me you are trying to understand where Documentsis.

在我看来,你正试图了解在哪里Documents

To do that open your terminal and type cd, that will change your current directory to your home folder.

为此,请打开您的终端并输入cd,这会将您的当前目录更改为您的主文件夹。

Once in your home, which should look like /c/Users/YOUR-USERNAME, type ls, your Documentsfolder is there.

进入您的家后,应该像/c/Users/YOUR-USERNAME键入ls,您的Documents文件夹就在那里。

tl;dr cd /c/Users/YOUR-USERNAME/Documents.

tl;博士cd /c/Users/YOUR-USERNAME/Documents

回答by Rupert Foggo McKay

Try

尝试

$ cd C:/Users/(YOURUSERNAME)/Desktop

If you are not sure what your username is, then try

如果您不确定您的用户名是什么,请尝试

$ cd C:/Users

Then this to see what options are available

然后这个看看有哪些选项可用

$ ls  

回答by Cpt. Stroparo

The home directory of cygwin based apps like babun, git-bash, mobaxterm etc. i.e. ~ or $HOME is not the same as windows.

基于 cygwin 的应用程序(如 babun、git-bash、mobaxterm 等)的主目录即 ~ 或 $HOME 与 Windows 不同。

Windows user path is in the %USERPROFILE% environment variable which in cygwin syntax is /c/Users/YOURUSER (or /cygdrive/c/Users/YOURUSER), like pointed out by the other answers.

Windows 用户路径位于 %USERPROFILE% 环境变量中,在 cygwin 语法中为 /c/Users/YOURUSER(或 /cygdrive/c/Users/YOURUSER),就像其他答案所指出的那样。

Also, Cygwin based apps handle HOME if it is already set to a custom path in Windows, see the Cygwin FAQ page: https://www.cygwin.com/faq.html#faq.setup.home

此外,如果 HOME 已经设置为 Windows 中的自定义路径,则基于 Cygwin 的应用程序会处理 HOME,请参阅 Cygwin 常见问题解答页面:https: //www.cygwin.com/faq.html#faq.setup.home

回答by Mohammad Zuha Khalid

Go to the Directory/Folder where you want to go .Right Click inside that folder and there will be an option called as Git Bash here. click on it .Then a terminal will open with the path of that directory .

转到您想去的目录/文件夹。在该文件夹内单击鼠标右键,此处将有一个名为 Git Bash 的选项。单击它。然后一个终端将打开,其中包含该目录的路径。

回答by mohammedkhan

If you run pwd(print working directory) you'll know where you are in your system's file structure and navigate from there.

如果您运行pwd(打印工作目录),您将知道您在系统文件结构中的位置并从那里导航。

Assuming you're on Mac OS X you probably want to do cd ~/Desktop(~is a shorthand way of getting to your home folder).

假设您使用的是 Mac OS X,您可能想要这样做cd ~/Desktop(这~是一种进入主文件夹的速记方式)。