Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a master branch and a dev branch for current development(local working copy). I need to merge changes from master onto my dev branch. Prior to merge I ran git stash and discovered the following error:

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

To investigate this error I ran the following commands: git status git branch git remote -v. All produced the same error fatal: Not a git repository (or any of the parent directories): .git

I also tried resetting the origin of my branch git remote set-url origin https://github.com/Connexions/oer.exports.git which produces the same result: fatal: Not a git repository (or any of the parent directories): .git

I cannot commit any changes from my local working directory onto my dev branch either.

Does anyone have any suggestions on how to correct this issue.

like image 438
Jessica Burnett Avatar asked Sep 10 '12 19:09

Jessica Burnett


People also ask

How do I fix fatal not a git repository or any of the parent directories?

To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.

What does fatal not a git repository or any of the parent directories ): .git mean?

What does “fatal: not a git repository” mean? This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right directory.

What is .git folder in github?

git init is one way to start a new project with Git. To start a repository, use either git init or git clone - not both. To initialize a repository, Git creates a hidden directory called . git . That directory stores all of the objects and refs that Git uses and creates as a part of your project's history.

Is .git folder committed?

A . git folder is required to log every commit history and every other information required for your remote repository, version control, commits etc. These things are saved in different folders which have different meanings. Once the folder is created, open it and see the contents of the folder.


1 Answers

Check the following file:

  • your_repo_dir/.git/HEAD

If this content seems corrupted, this is the issue. I had the similar issue and I fixed it by replacing the content of the HEAD file with the git commit hash of the last commit from selected branch.

Commit hashes could be found under the .git/logs/refs/heads and branch_name_file

I hope it helps.

like image 159
Jernej Gololicic Avatar answered Nov 15 '22 04:11

Jernej Gololicic