Home > Blockchain >  Cannot add parent directory to safe.directory on git
Cannot add parent directory to safe.directory on git

Time:04-13

After updating git to v2.35.2.windows.1 I'm getting the following error:

fatal: unsafe repository ('F:/GitHub/my-project' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory F:/GitHub/my-project

I've tried adding the parent directory of my projects to .gitconfig but it doesn't work.

[safe]
    directory = F:/GitHub/
    directory = F:/Private/
  • Is there a workaround for this? I don't want to add every single project I'm working on to the .gitconfig file.

  • What does it actually mean by "'x' is owned by someone else"? As far as .gitconfig is concerned user.name and user.email are the same.

Note: I'm using enter image description here

CodePudding user response:

We have fixed this issue by fixing the .git/objects permissions. We were actually unable to add files without sudo because of the bad permissions.

CodePudding user response:

In my case, on an Ubuntu 20.04.4 system, the project folder had the ownership set to the application user e.g www-data:www-data, but the .git folder when initiated had it's ownership set to root:root.

To fix this issue I changed the ownership on my project folder to root:root so as to match it's contents (including .git folder). Then all git actions started working as normal.

CodePudding user response:

In my case case I just copy the message and write sudo then pest the massage. After pressing enter button the issue have gone

For example :

sudo git config --global --add safe.directory your-path 

your path = as shown in message

  •  Tags:  
  • git
  • Related