[Solved] Cannot add parent directory to safe.directory on git

Github Faysal Shuvo


Problem: 

I updated git to v2.35.2.windows.1. When I try to give any git command it gives me the following error:

fatal: unsafe repository ('E:/GitHub/todo-project' is owned by someone else)
To add an exception for this directory, call:
        git config --global --add safe.directory E:/GitHub/todo-project

To solve this problem, I added my project to .gitconfig but it does not work. 

So in this article, we are going to learn  How to solve the cannot add parent directory to safe.directory on git - this problem. 


Solution: 

The problem you are describing is git's new security vulnerability. It has nothing to do with your email. The problem is you are not the owner of the directories of that file system. So check, If the user you are currently logged in to is also the owner of the folder. If you are not the owner but need multiple owners your folder to the multi-value safe.directory config setting:

git config --global --add safe.directory E:/GitHub/todo-project

and remember to call git within this folder.

E:/GitHub/todo-project

Hope this article helps you with your problem. If you have any more questions please comment below.