Thread (1 message) 1 message, 1 author, 2016-06-15

Re: A question about changing remote repo name

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:58

Russell Steicke [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help