git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to have multiple working copy directories use the same repository?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 12, 2007, 03:52 UTC
Message-ID
<20071012035219.GB27899@spearce.org>
In-Reply-To
<20071011190025.GC2804@steel.home>
Alex Riesen <raa.lkml@gmail.com> wrote:
Show 8 quoted lines
> Bill Priest, Thu, Oct 11, 2007 20:10:50 +0200:
> >   I've looked at the "git for CVS users" section in
> > the docs and this appears to create two repositories. 
> > Is there a way to have two working directories that
> > utilize the same repository?
> 
> Look for "alternates" in git's documentation. But read all the
> warnings regarding git-gc and git-prune. Make a note of ".keep" files.
Really I think Bill wants the contrib/workdir/git-new-workdir script.

Its downside is that it makes heavy use of symlinks under the .git directory for the secondary working directories, and you do have to watch out for committing changes to a branch when more than one working directory has that branch as its current branch. But otherwise it works very well for this use case.

Also you may get a few warnings from your HEAD reflog saying objects no longer exist when you do a git-gc within a working directory. This can happen for example if you use `git rebase -i` in a working directory a few times and then later run git-gc from a different working directory. But since its just intermediate rebase state its probably not that big of a deal to have it go missing.

You shouldn't run `git gc --prune` if any of the working directories has staged but uncommitted changes in them. Such changes are held in the working directory's index, which will not be considered as reachable (as it isn't visible to git-gc) and the objects will be pruned. That would not too be pleasant to debug.

Heh.  As you can see it has some "issues" with its use.  Its a very
powerful tool, but it does give you more than enough room to shoot
yourself in the foot.  Using it is like tieing a gun to your ankle,
keeping it aimed at your big toe at all times, with a string tied
to your wrist and the gun's trigger.  Reach too far and *bam*.
Which is why its still in contrib status.
 
-- 
Shawn.
Previous: Alex RiesenNext: Sergio
Message 3 of 4 in “How to have multiple working copy directories use the same repository?”
  1. Bill PriestOct 11, 2007
  2. Alex RiesenOct 11, 2007
  3. Shawn O. PearceOct 12, 2007
  4. SergioOct 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.