Attempting to `git add all` fails

I am attempting to run git add --all in a new project folder. The host I am running this command from is Ubuntu. Here is the error message that I am receiving:

fatal: detected dubious ownership in repository at '/etc/ansible'

To add an exception for this directory, call:

        git config --global --add safe.directory /etc/ansible

I am the ansible user, and here are the directory permissions:

drwxrwx--- 5 root ansible      14 Jan 12 14:35 ansible

Did a bit of research, and was told not to run this command unless you know what it does. I am also trying to go by best practices.

Phew, this seems to be a relatively new feature of Git. I did some reading and found a possible explanation in cron - Git "fatal: detected dubious ownership in repository" - Ask Ubuntu

The owner is root and the group is ansible.

If you are the ansible user in the ansible group executing the command, Git still thinks that only root:ansible is allowed to add the files.

  • :white_check_mark: root:ansible
  • :x: ansible:ansible

Probably it is safe to add this as a safe directory using git config --global --add safe.directory /etc/ansible and continue working as low privileged users. I would not recommend changing the file system permissions - this could break Ansible itself, or the package where it is installed from (or on upgrades, permissions are reset again).

1 Like