Skip to content

Adding the git add safe option

Compare
Choose a tag to compare
@fr3nch13 fr3nch13 released this 30 Jun 20:18
· 6 commits to main since this release
fa3ffae

The VersionsHelper uses git to detect which tag/branch that the root application is running.

Git detects if the user that is running the git command is also the owner of the git repository. If the user isn't the owner of the repository, as in the possible case of apache/web server, git will throw an error fatal: detected dubious ownership in repository.

I've added the ability to try to mark the repo as safe by automatically running git config --global --add safe.directory ' . $this->getRootDir(); however, this may not be enough, and you may need to change the owner of the repository to the user that apache/web server runs under.

Apache usually runs under either apache or www-data on Linux systems.
To find out for yourself which user is running apache:

  • start apache
  • run this command ps -ef | egrep '(httpd|apache2|apache)' | grep sbin | grep -v root | head -n1 | awk '{print $1}'.