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

Re: A question about changing remote repo name

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 6, 2010, 01:02 UTC
Message-ID
<7vd41oqc3h.fsf@alter.siamese.dyndns.org>
In-Reply-To
<c1b8b6671001051607j6b6398d8gf08f7615a38de64e@mail.gmail.com>
Russell Steicke <russellsteicke@gmail.com> writes:
> Ah yes, I forgot about those files.  I _think_ (but I'm not certain
> without digging into the code) that it's always safe to rm
> packed-refs, as that file is a cache for quicker access to the refs.

No what you think is incorrect, no it is not safe at all, and no it is not a cache.

refs are created loose as files under $GIT_DIR/refs/. When pack-refs is run (either from the toplevel or as part of gc), these loose ref files are removed and instead written to $GIT_DIR/packed-refs file. When a new ref is created or an existing ref is updated, only $GIT_DIR/refs/ is modified.

When reading or enumerating, a loose ref, if found, is used. Otherwise a record in packed-refs is consulted. The consequences are:

 - If you have $GIT_DIR/refs/heads/master and at the same time, an entry
   for refs/heads/master exists in $GIT_DIR/packed-refs, removing the
   entry in packed-refs happens to be safe, because it was already masked.
 - If you do not have $GIT_DIR/refs/heads/old, but an entry for
   refs/heads/old exists in $GIT_DIR/packed-refs, removing the entry in
   packed-refs means you lose the "old" branch.  You don't want to do
   that.
 - When deleting a ref, we remove it from $GIT_DIR/refs/, but at the same
   time, if packed-refs contains an entry for it, we remove it from
   there.  Otherwise, the removal of the loose one will unmask the stale
   entry in packed-refs file.
Previous: Russell SteickeNext: Dongas
Message 13 of 14 in “A question about changing remote repo name”
  1. DongasJan 4, 2010
  2. Miklos VajnaJan 4, 2010
  3. DongasJan 5, 2010
  4. Erik Faye-LundJan 5, 2010
  5. DongasJan 5, 2010
  6. Russell SteickeJan 5, 2010
  7. DongasJan 5, 2010
  8. David AguilarJan 5, 2010
  9. DongasJan 6, 2010
  10. Russell SteickeJan 6, 2010
  11. Johannes SchindelinJan 6, 2010
  12. Russell SteickeJan 7, 2010
  13. Junio C HamanoJan 6, 2010
  14. DongasJan 6, 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.