We'd like to use git to maintain system configurations. Because sometimes configuration data exists outside of /etc, we've started doing something like this on our systems:
# cd /
# git init
# git add etc
# git add some/other/path
# git commit -m 'initial import'
And so forth. This works, up to a point. As long as your cwd == '/', git behaves normally. However, if you try, for example, to run git from inside a subdirectory:
cd /etc
git status
You get garbage. In our case, thousands of lines of "deleted:" listings for files that clearly still exist. This behavior appears to be exclusive to running git in /; doing the same thing anywhere else works just fine.
I can "fix" the behavior like this:
GIT_WORK_TREE=/ git status
And hey, everything works the way Linus intended...but this is a pain. I don't want to set it in the environment unilaterally (because this would conflict with the use of git in other repositories), and I'd like to avoid a wrapper script. Do I have any other options?