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 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.

It can also be cause because of a GIT_WORK_TREE environment variable being set to the wrong path. Or it is seen in wrappers using git repo like rvm (see this thread for example)

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:

  • 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.

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.

Need Your Help

Storing functions within arrays

javascript jquery arrays object-literal

I'm having a issue with something very simple. I am just wondering as to I can store these functions within an array. Check out some of the code below. I am unsure as to if this is correct as to ho...

Excel VBA Run-time error '13' Type mismatch when value isnt numerical

excel vba numerical mismatch

I have the below code that's returning a mismatch error when the value isn't numerical. What would I change?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.