Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

#!/bin/bash
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?

share|improve this question
    
the title is wrong, but i have no idea what else to title this question –  NixNinja Sep 9 '10 at 13:36
add comment

2 Answers

up vote 3 down vote accepted

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

   --git-dir=<path>
       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:

#!/bin/bash
sudo git --git-dir=/.git $@ > /dev/stdout

FTR, I haven't tried it.

share|improve this answer
    
works like a charm –  NixNinja Sep 9 '10 at 17:47
add comment

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.

share|improve this answer
add comment

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.