Re: I don't want the .git directory next to my code.

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

 



On Tue, Jan 15, 2008 at 11:13:58PM -0500, Daniel Barkalow wrote:
> export GIT_DIR=/somewhere-else.git
> 
> Note that this only really works if you've only got one repository; 
> there's no good way to have the repository information outside of the 
> working directory and still have which repository you're using depend on 
> which directory you're working in.

If you use zsh as your shell, put this chpwd function in .zprofile or
.zshrc:

chpwd() {
    local gitbasedir=/var/local/git
    local subdir=$gitbasedir$PWD
    while [[ ! -d $subdir ]]; do
	subdir=${subdir:h}
    done
    if [[ -d $subdir/.git ]]; then
	export GIT_DIR=$subdir/.git
	export GIT_WORK_TREE=${subdir/$gitbasedir/}
    else
	unset GIT_DIR GIT_WORK_TREE
    fi
}

Then, for each /path/.git dir, move it to /var/local/git/path/.git
(creating any needed parent dirs).  On every change of directory in
the shell, the variables GIT_DIR and GIT_WORK_TREE will be either
updated or cleared.  If you ever move a work-tree dir, you'll need
to remember to move the .git dir in the /var/local/git hierarchy.

..wayne..
-
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