Search code examples
gitrepositoryini

I am unable to run any git commands ("not a git repository" error)


I have a local project, and I use git for version control. Nothing is pushed online, everything is on my PC.

Until today, everything worked as it should. Today, I tried to enter git status, and I got the following message:

Fatal: not a git repository (or any of the parent directories)

I have also tried other commands as git add . but nothing works. I have checked, and there is .git folder, with files and folders inside it. Then, I tried, git init, but I got the following message:

Reinitialized existing Git repository in...

Just to make sure, I opened the folder where the .git folder is, I right-clicked, and selected Git bash here..., So I must be in the right folder.

I don't mind losing changes I've made so far, but I would like to have working git, without the need to copy everything to a new folder, if possible.

I appreciate any help.

Thanks.


Solution

  • As Bagus Tesa suggested, I've completely removed the .git folder and initialized a new one with git init. All previous data is removed, but at least everything works now.