git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Chris Jerdonek <chris.jerdonek@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: create reflog for reflog-less ref
Date: Wed, 26 Feb 2020 02:39:09 +0000	[thread overview]
Message-ID: <20200226023909.GC7911@camp.crustytoothpaste.net> (raw)
In-Reply-To: <CAOTb1wc2uMSyc7DMau2cWrWtk=_Z94+CCovORj1dGCrwgJhL=w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1744 bytes --]

On 2020-02-26 at 01:07:35, Chris Jerdonek wrote:
> Hi,
> 
> I wanted to ask on this list if there are any supported ways to create
> a reflog for an existing ref that doesn't already have a reflog.
> 
> This is more likely to come up for refs not in the standard set (i.e.
> HEAD, branches and remote-tracking branches), since reflogs aren't
> created by default for those refs.
> 
> The only workaround I could think of is using git-update-ref to delete
> the ref, and then immediately recreate it using the `--create-reflog`
> option (if that option is needed), e.g.:
> 
> $ git update-ref -d refs/foo/bar
> $ git update-ref -m "my message" --create-reflog refs/foo/bar <SHA>
> 
> This seems hacky though because it forces you to pass through a state
> where the ref no longer exists. It also requires you to get the ref's
> SHA first.
> 
> This Stack Overflow reply from 2016 suggests the idea of using `git
> update-ref -m MSG REF REF` to add lines to an existing reflog:
> https://stackoverflow.com/questions/36770141/can-i-add-a-line-to-the-reflog/36778898#36778898
> But it doesn't seem to work to create a reflog (and only seemed to
> work for me in limited circumstances otherwise, like adding to HEAD's
> reflog). (I tried with version 2.25.0.)

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.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  reply	other threads:[~2020-02-26  2:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26  1:07 create reflog for reflog-less ref Chris Jerdonek
2020-02-26  2:39 ` brian m. carlson [this message]
2020-02-26  3:47   ` Jeff King
2020-02-26  7:18     ` Chris Jerdonek
2020-02-26  9:47       ` Jeff King
2020-02-26 10:21         ` Chris Jerdonek
2020-02-26 18:40           ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226023909.GC7911@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=chris.jerdonek@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).