git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* create reflog for reflog-less ref
@ 2020-02-26  1:07 Chris Jerdonek
  2020-02-26  2:39 ` brian m. carlson
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Jerdonek @ 2020-02-26  1:07 UTC (permalink / raw)
  To: git

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.)

Any thoughts?

Thanks,
--Chris

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-02-26 18:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-26  1:07 create reflog for reflog-less ref Chris Jerdonek
2020-02-26  2:39 ` brian m. carlson
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

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 NNTP newsgroup(s).