Git not longer identified by terminal

Viewed 124

I was working on a project for many weeks now and I'm having this error when trying to add new changes to git, suddenly:

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

My terminal is not recognizing my project as a git repository anymore, so it's not running git commands. I know I could create a new one by running git init, but would that restart of all my branch progress on Github from zero if I push it? If so, is there still a way to push it without losing track?

2 Answers

I've been through this recently when cloning an older commit, making new changes and trying to re-push it. Git wasn't recognizing my project anymore.

What solved it for me was, instead of cloning it using the HTTPS URL as usual, I've used the SSH one (which is password protected by an SHH key). With that, I've made the needed changes and pushed it to the existing repository, instead of initializing a new one and losing my commit history.

It must an issue related the token authentication system provided by Github: https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/

Hope that works for you as well. Let me know.

The cause of issue could be that

  • The project you are working upon is not a git versioned project at all.
  • You may be at a higher folder for your project path which is not a git versioned folder.

Things to try:

  • If the project is not git versioned. Go to the root folder of project and do a git init and git add . and git commit -m "Initial commit" and your project will be git versioned.
  • Go the the project root folder and then try git commands.
Related