简体   繁体   English

git bash“不是git存储库”错误

[英]git bash “Not a git repository” error

I cloned one of my projects in windows desktop and after editing when I input git add . 我在Windows桌面上克隆了我的一个项目,并在编辑后输入git add . command then I get following error: 命令然后我得到以下错误:

fatal: Not a git repository (or any of the parent directories): .git 致命的:不是git存储库(或任何父目录):。git

How to solve this? 怎么解决这个?

When you type git clone it will create a subdirectory in the current directory. 当您键入git clone ,它将在当前目录中创建一个子目录。 eg If your current working directory is /code , the command line output could look similar to this: 例如,如果您当前的工作目录是/code ,则命令行输出可能类似于:

$ pwd
/home/you/code [or something similar]
$ ls -F
foo  bar
$ git clone http://somewhere.baz/somerepo.git
[happy git output]
$ ls -F
foo  bar  somerepo/

as you see you repo was cloned to the somerepo subdirectory, so the full path would be something like ~/code/repo_name . 如你所见,repo被克隆到somerepo子目录,所以完整的路径就像~/code/repo_name However, your current working directory remains the same, ~/code . 但是,您当前的工作目录保持不变, ~/code

Next, you should step into that directory: 接下来,您应该进入该目录:

$ cd somerepo
$ ls
[content of your repo]

After you've changed the current working directory, you should be able to see its content (output of ls command), and be able to see git repository state with the git status command. 在更改了当前工作目录之后,您应该能够看到其内容( ls命令的输出),并能够使用git status命令查看git存储库状态。

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

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