Re: Managing multiple branches in git - Mailing list pgsql-hackers

From Aidan Van Dyk
Subject Re: Managing multiple branches in git
Date
Msg-id 20090602171119.GH23972@yugib.highrise.ca
Whole thread Raw
In response to Re: Managing multiple branches in git  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
* Tom Lane <tgl@sss.pgh.pa.us> [090602 12:35]:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
> > Hmm, but is there a way to create those clones from a single local
> > "database"?
> 
> > (I like the monotone model much better.  This mixing of working copies
> > and databases as if they were a single thing is silly and uncomfortable
> > to use.)
> 
> I agree, .git as a subdirectory of the working directory doesn't make
> much sense to me.

The main reason why git uses this is that the "index" (git equivilant of
the CVS/*) resides in 1 place instead of in each directory.  So, if you
have multiple working directories sharing a single .git, you get them
tromping on each others "index".

That said, you can symlink almost everything *inside* .git to other
repositories.

For instance, if you had the "Reference" repository I shows last time,
instead of doing the "git clone", you could do:
#Make a new REL8_2_STABLE working areamountie@pumpkin:~/pg-work$ REF=$(pwd)/PostgreSQL.gitmountie@pumpkin:~/pg-work$
mkdirREL8_2_STABLEmountie@pumpkin:~/pg-work$ cd REL8_2_STABLE/mountie@pumpkin:~/pg-work/REL8_2_STABLE$ git init
 
# And now make everything point backmountie@pumpkin:~/pg-work/REL8_2_STABLE$ mkdir .git/refs/remotes && ln -s
$REF/refs/heads.git/refs/remotes/originmountie@pumpkin:~/pg-work/REL8_2_STABLE$ rm -Rf .git/objects && ln -s
$REF/objects.git/objectsmountie@pumpkin:~/pg-work/REL8_2_STABLE$ rmdir .git/refs/tags  && ln -s $REF/refs/tags
.git/refs/tagsmountie@pumpkin:~/pg-work/REL8_2_STABLE$rm -Rf .git/info && ln -s $REF/info
.git/infomountie@pumpkin:~/pg-work/REL8_2_STABLE$rm -Rf .git/hooks && ln -s $REF/hooks
 

This will leave you with an independent config, independent index,
independent heads, and independent reflogs, with a shared "remote"
tracking branches, shared "object" store, shared "tags", and shared
hooks.

And make sure you don't purge any unused objects out of any of these
subdirs, because they don't know that the object might be in use in
another subdir...  This warning is the one reason why it's usually
recommended to just use a reference repository, and not have to worry..

a.

-- 
Aidan Van Dyk                                             Create like a god,
aidan@highrise.ca                                       command like a king,
http://www.highrise.ca/                                   work like a slave.

pgsql-hackers by date:

Previous
From: Ron Mayer
Date:
Subject: Re: Managing multiple branches in git
Next
From: Mark Mielke
Date:
Subject: Re: Managing multiple branches in git