4

I cloned a repo with git clone <path to repo> but when I run git status I get the fatal: not a git repository error.

What I want to know is, if I run git init in the local directory that was cloned, will it screw anything up or cause issues with the initial repo on GitHub?

I cd && ls -a into a few directories but I don't see the .git file.

So I first did a search with $ git ls-files | grep .git and got the same fatal no repo error.

Then I did a search with $ find . | grep .git and it listed 3 .gitignore files. Which I assume means the initial creator didn't initialize git.

I want to create a branch and begin working and making commits without messing up the original repo.

I've referenced these following StackOverflow questions but they don't give me the answer I need:

"fatal: Not a git repository (or any of the parent directories)" from git status

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

Community
  • 1
  • 1
FrankDraws
  • 385
  • 1
  • 6
  • 21
  • 1
    Is what you're trying to clone an actual repo then? On the remote box, if you change into that directory, what does `git status` give you? – Makoto May 28 '15 at 15:27
  • sorry for the stupid question but, did you actually `cd` into the directory after cloning before typing `git status`? – Sébastien Dawans May 28 '15 at 16:40
  • @SébastienDawans Not a stupid question. Yes I did. – FrankDraws May 28 '15 at 17:13
  • @Makoto Not sure I follow. The original directory is on GitHub. Is it possible to run `git status` on that repo remotely? – FrankDraws May 28 '15 at 17:15
  • No (except if you have access to the shell at the Github servers, which would only be the case, if you're working there as an admin). – dunni May 28 '15 at 17:33

2 Answers2

4

Your repository seems to be broken. Make sure that you didn't erased by error the .git folder after cloning. Maybe, just clone again and work from that new clone.

  • 1
    I deleted the repo and cloned it again like you suggested but this time I used the GitHub GUI app. Then I `cd && ls -a` into the directory and the `.git` file shows up. Thanks @MatthieuPizenberg – FrankDraws May 29 '15 at 14:47
  • Confirmed that using GitHub Desktop app to do the clone instead of clone from CLI worked to restore the .git file (thanks Frank). Cloning from CLI results in no local .git repo. Seems like a bug, not sure why cloning one way would be different than another. I'm on MacOS 10.11 El Cap, GitHub Desktop 222, git CLI version 2.9.3 (Apple Git-75). – Ben Stahl Oct 11 '16 at 03:04
2

I think .git file might be hidden.

To fix this go to "Folder Options" then press "show hidden files, folders and drives".

Then do not forget to navigate into the folder where .git resides.

This may fix it, if I got your problem right.

Cheers.

GuD
  • 101
  • 1
  • 2