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

Re: create reflog for reflog-less ref

From
Jeff King <peff@peff.net>
Date
Feb 26, 2020, 03:47 UTC
Message-ID
<20200226034731.GA2915944@coredump.intra.peff.net>
In-Reply-To
<20200226023909.GC7911@camp.crustytoothpaste.net>
On Wed, Feb 26, 2020 at 02:39:09AM +0000, brian m. carlson wrote:
Show 8 quoted lines
> There is the option core.logAllRefUpdates, which has the value "always"
> in more modern versions of Git.  The documentation says,
> 
>   If [the option is set to always, then a missing reflog is
>   automatically created for any ref under refs/.
> 
> Now, that assumes that you want reflogs for all your refs, but there's
> really not much downside to having a reflog and not using it.

The current rule is actually to append to any reflog that already exists, or to consult core.logAllRefUpdates when deciding whether to create one that doesn't exist. So I think setting a one-shot config variable like:

  git -c core.logAllRefUpdates=always update-ref refs/foo/bar ...

would create the reflog, and then any subsequent updates (even without that config set) would append to it.

You can also do this:
  mkdir -p .git/logs/refs/foo/
  touch .git/logs/refs/foo/bar
  git update-ref refs/foo/bar ...

but I wouldn't recommend it. When we eventually move to supporting other ref backend formats, they won't necessarily store the logs in the same way.

-Peff
Previous: brian m. carlsonNext: Chris Jerdonek
Message 3 of 7 in “create reflog for reflog-less ref”
  1. Chris JerdonekFeb 26, 2020
  2. brian m. carlsonFeb 26, 2020
  3. Jeff KingFeb 26, 2020
  4. Chris JerdonekFeb 26, 2020
  5. Jeff KingFeb 26, 2020
  6. Chris JerdonekFeb 26, 2020
  7. Jeff KingFeb 26, 2020

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.