I'm running a local dev server on Apache. I have a script (written in PHP) that scans all of the local dev sites I have up and running, and tells me which have outstanding items to commit to git. When I run git status
as my own user, git ignores the files set in my .gitignore file. But when I run the command via Apache/PHP, those files are not ignored.
I'm not sure I'm explaining that very well, so by way of a demonstration, I have a folder with three files:
file1.txt
file2.php
file3.backup
My gitignore contains this line, to ignore all backup files:
*.backup
When I run the git status
command manually, I see this (with the backup file correctly ignored):
dave$ git status
file1.txt
file2.php
If I run exec('cd /dir/ && git status -s /dir/', $output);
from PHP, I see:
file1.txt
file2.php
file3.backup
The backup file shows up as an unversioned file.
I don't want to set the gitignore on a per-repo basis. Is there any way I can get my www-data user to use a gitignore? Or is there a higher-level gitignore setting for all users on a machine?
You can set a global .gitignore using the following configuration command:
Note that the filename could be whatever you want, in the example I've used
.gitignore_global