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

Re: Retrospectively add alternates to a repository?

From
SFSteve Folly <steve@spfweb.co.uk>
Date
Feb 27, 2010, 11:43 UTC
Message-ID
<loom.20100227T123539-643@post.gmane.org>
In-Reply-To
<20100227083418.GC27191@coredump.intra.peff.net>
Jeff King <peff <at> peff.net> writes:
Show 40 quoted lines
> 
> On Sat, Feb 27, 2010 at 10:37:25AM +0800, Tay Ray Chuan wrote:
> 
> > yes, just make sure the objects/info/alternates file points to the
> > location of that cloned repo's object directory; for example:
> > 
> >   $ echo /path/to/cloned/repo/.git/objects > .git/objects/info/alternates
> 
> You will probably want to then get rid of anything in the child that is
> now available in the alternates repository.
> 
> I would have thought "git repack -adl" works, but I think there is
> something a little funny in the logic. It reports "nothing new to pack",
> but does not delete the loose objects. But packing first then worked:
> 
>   $ git clone large-parent child
>   $ echo $PWD/large-parent/.git/objects >child/.git/objects/info/alternates
>   $ cd child
> 
>   $ du -sh .git/objects
>   51M     .git/objects
> 
>   $ git repack -adl && du -sh .git/objects
>   Nothing new to pack.
>   51M     .git/objects
> 
>   $ git repack -ad && du -sh .git/objects
>   Counting objects: 3, done.
>   Delta compression using up to 2 threads.
>   Compressing objects: 100% (2/2), done.
>   Writing objects: 100% (3/3), done.
>   Total 3 (delta 0), reused 0 (delta 0)
>   51M     .git/objects
> 
>   $ git repack -adl && du -sh .git/objects
>   Nothing new to pack.
>   20K     .git/objects
> 
> -Peff
> 
Excellent, this is exactly what I need. Thanks very much Tay
 and Jeff.

I now have a plan to write a script to attach and detach repositories to and from local mirrors on demand:

attach = 
    echo "/path/to/mirror" > .git/objects/info/alternates && 
    git repack -adl && 
    git repack -ad && 
    git repack -adl
detach = 
    git repack -a && 
    rm .git/objects/info/alternates

Cheers, Steve

Previous: Jeff KingNext: Jeff King
Message 4 of 7 in “Retrospectively add alternates to a repository?”
  1. Steve FollyFeb 26, 2010
  2. Tay Ray ChuanFeb 27, 2010
  3. Jeff KingFeb 27, 2010
  4. Steve FollyFeb 27, 2010
  5. Jeff KingFeb 27, 2010
  6. Felipe ContrerasMay 16, 2010
  7. Jeff KingMay 22, 2010

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.