Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 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

share|improve this answer
    
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 '13 at 8:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.