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.
One way to get that error message is to somehow not be in the git repo working tree. See "After git clone I get a “ fatal: Not a git repository (or any of the parent directories): .git ” error" as an illustration.
In both case, resetting the situation in a new clone (which you did) usually is a good way to fix the situation.
Check the following file:
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.
I had this error after having problems with visual studio git plugin.
The solution was to rename my_repo_dir/.git/HEAD.lock to my_repo_dir/.git/HEAD
Looks like something crashed after locking the head file and that killed the repo.
Had the same problem after I tried to push the branch to remote from Visual Studio. I renamed .git/HEAD.lock to .git/HEAD after checking its content. Now it works fine.