简体   繁体   中英

git bash “Not a git repository” error

I cloned one of my projects in windows desktop and after editing when I input git add . command then I get following error:

fatal: Not a git repository (or any of the parent directories): .git

How to solve this?

When you type git clone it will create a subdirectory in the current directory. eg If your current working directory is /code , the command line output could look similar to this:

$ 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 . However, your current working directory remains the same, ~/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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