Re: how to git a read only directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux