git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git <git@vger.kernel.org>, cbill.lam@gmail.com
Subject: Re: how to git a read only directory
Date: Wed, 21 Jan 2009 10:57:41 +0100	[thread overview]
Message-ID: <4976F195.9030908@drmicha.warpmail.net> (raw)
In-Reply-To: <20090121083354.GG6970@b2j>

bill lam venit, vidit, dixit 21.01.2009 09:33:
> I want to use git to keep track of files inside /etc but do not want
> to do it as a super user. Is that possible to put GIT_DIR under my
> home directory and add public-read files inside /etc? Or that it could
> be done in some other ways.
> 
> Thanks.
> 

You can use the core.worktree config variable in order to specify a
worktree (/etc) which is not directly above .git. For your git commands
to find the .git dir you would need to set GIT_DIR or use the --git-dir
parameter.

I have found, though, that several git commands require you to be within
the worktree or else they become confused. I use a shell function for
that, doing something like "gg ~/path/project log" which requires
~/path/project.git to have its core.worktree set. Also, having a git
alias like "git view" set up for gitk helps calling gitk in that way.
git-gui makes unfounded assumptions and is completely unhappy in a
situation like that.

I think the situation around GIT_DIR and and worktree is a bit in the
flux at the moment (panta rhei..) but it works for me.

Cheers,
Michael

Here's the "git go" bash function. I'm not proud of it, it makes several
assumptions and does no error checking. Use it like "gg path/project
command parameters" if the git-dir is "path/project.git" or "gg
path/project/" if the git-dir is "path/project/.git". Have your
core.worktree set in the former case, and also in the latter if the
worktree is not "path/project".

I'm sure it can be done much better using helper functions from git's
bash-completion, e.g.

gg ()
{
    local _gg="$1";
    shift;
    local _ggwt=`git --git-dir="${_gg}.git" config --get core.worktree`;
    if [ -z "${_ggwt}" ]; then
        _ggwt=$(cd ${_gg} 2> /dev/null && pwd -P);
    fi;
    local _gggd=$(cd ${_gg}.git 2> /dev/null && pwd -P);
    pushd ${_ggwt} > /dev/null;
    git --git-dir=${_gggd} "$@";
    popd > /dev/null
}

  reply	other threads:[~2009-01-21  9:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-21  8:33 how to git a read only directory bill lam
2009-01-21  9:57 ` Michael J Gruber [this message]
2009-01-21 15:48   ` bill lam
2009-01-21 12:34 ` Boaz Harrosh
2009-01-21 15:52   ` bill lam
2009-01-21 16:46     ` Boaz Harrosh
2009-01-22 10:00       ` bill lam
2009-01-22 10:19         ` Boaz Harrosh
2009-01-22 10:29           ` bill lam
2009-01-22 12:35             ` Boaz Harrosh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4976F195.9030908@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=cbill.lam@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).