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

Re: Git gc removes all packs

From
Jeff King <peff@peff.net>
Date
Feb 5, 2015, 20:03 UTC
Message-ID
<20150205200332.GD15326@peff.net>
In-Reply-To
<CAC+L6n1M7LtGaJy94fnhXm94zJ32HXLNVGMguWSqHm=qqLLDxA@mail.gmail.com>
On Thu, Feb 05, 2015 at 04:13:03PM +0100, Dmitry Neverov wrote:
Show 5 quoted lines
> I'm using git p4 for synchronization with perforce. Sometimes after 'git
> p4 rebase' git starts a garbage collection. When gc finishes a local
> repository contains no pack files only loose objects, so I have to
> re-import repository from perforce. It also doesn't contain a temporary
> pack git gc was creating.

It sounds like git didn't find any refs; it will pack only objects which are reachable. Unreachable objects are either:

  1. Exploded into loose objects if the mtime on the pack they contain
     is less than 2 weeks old (and will eventually expire when they
     become 2 weeks old).
  2. Dropped completely if older than 2 weeks.
Show 6 quoted lines
> One more thing about my setup: since git p4 promotes a use of a linear
> history I use a separate repository for another branch in perforce. In
> order to be able to cherry-pick between repositories I added this
> another repo objects dir as an alternate and also added a ref which is a
> symbolic link to a branch in another repo (so I don't have to do any
> fetches).

You can't symlink refs like this. The loose refs in the filesystem may be migrated into the "packed-refs" file, at which point your symlink will be broken. That is a likely reason why git would not find any refs.

So your setup will not ever work reliably. But IMHO, it is a bug that git does not notice the broken symlink and abort an operation which is computing reachability in order to drop objects. As you noticed, it means a misconfiguration or filesystem error results in data loss.

-Peff
Previous: Dmitry NeverovNext: Michael Haggerty
Message 2 of 10 in “Git gc removes all packs”
  1. Dmitry NeverovFeb 5, 2015
  2. Jeff KingFeb 5, 2015
  3. Michael HaggertyFeb 17, 2015
  4. Jeff KingFeb 17, 2015
  5. Michael HaggertyFeb 17, 2015
  6. Junio C HamanoFeb 17, 2015
  7. Michael HaggertyFeb 17, 2015
  8. Junio C HamanoFeb 18, 2015
  9. Dmitry NeverovFeb 27, 2015
  10. Jeff KingFeb 27, 2015

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.