I have a bash script, called cgit, that acts as git for one specific git repo (located at /.git):

cd /;
sudo git $@ > /dev/stdout

I use it to keep track of imporant system files:

cgit add /etc/rc.conf

The trouble is when I try to add content relative to the directory I'm in, for example:

cd /home/user
cgit add .ssh/config

cgit would try and add /.ssh/config to the /.git repo.

Any suggestions or work-arounds?

  • the title is wrong, but i have no idea what else to title this question
    – Stefan
    Sep 9, 2010 at 13:36

2 Answers 2


I'd update your cgit script to use --git-dir. From the man pages:

       Set the path to the repository. This can also be controlled by
       setting the GIT_DIR environment variable. It can be an absolute
       path or relative path to current working directory.

So it would become:

sudo git --git-dir=/.git $@ > /dev/stdout

FTR, I haven't tried it.

  • works like a charm
    – Stefan
    Sep 9, 2010 at 17:47

Much better to use etckeeper instead of your own home-grown solution. There are number of gotchas that etckeeper addresses nicely. It's a package in several Linux distros, and is also easy to build from source.

A really nice feature on Debian-based systems is that it ties in with apt to automatically commit before and after installing or updating packages. This helps distinguish changes you made yourself from ones made by package updates. It also (optionally) does a daily autocommit.

You must log in to answer this question.

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