1

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?

1 Answer 1

1

You can set a global .gitignore using the following configuration command:

git config --global core.excludesfile /path/to/.gitignore_global

Note that the filename could be whatever you want, in the example I've used .gitignore_global

1
  • Doesn't that just set it for your user, though, not all users? The global refers to all repositories, not all users and all repositories.
    – Dave Child
    Feb 22, 2013 at 8:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .