7

I noticed in the documentation you can specify the parameter --grep-reflog

--grep-reflog=<pattern>

Limit the commits output to ones with reflog entries that match the specified pattern (regular expression). With more than one --grep-reflog, commits whose reflog message matches any of the given patterns are chosen. It is an error to use this option unless --walk-reflogs is in use.

I kind of wanted clarification on how this is different from --grep. What benefit is there for looking through actions made through the git reflogs? Is it just so you know what is available in git reflog so if you wanted to access it, you can?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
aug
  • 11,138
  • 9
  • 72
  • 93

1 Answers1

6

--grep only search applies to commits reachable from a branch head. You would use --grep-reflog to search instead commits that are accessible from a reflog entry, which might not otherwise be accessible from an existing branch. I think this is useful primarily for error recovery (finding a commit that is otherwise lost so that you can recover it).

chepner
  • 497,756
  • 71
  • 530
  • 681
  • I guess my confusion is that specifying the `--walk-reflogs` parameter automatically includes the reflogs and you can use `--grep` along with that. Also it seems you can't use `--grep-reflog` unless you specify `--walk-reflogs`. Is there a specific benefit to using that as opposed to just `--grep`? – aug Apr 08 '15 at 20:30
  • Hm. I suspect the benefit is to limit the output to a manageable number of commits (my test with `--grep-reflog` showed only a single commit, even though there were numerous reachable commits found by `--grep` alone). This is probably not the best (or even a correct) answer to your actual question, though. – chepner Apr 08 '15 at 20:37
  • I'm gonna accept your answer for now since it seems that's the best we can figure out :P thanks! – aug Sep 12 '16 at 21:19
  • One difference I noticed is that `--grep` doesn't seem to work with `reflog` only `--grep-reflog`. – DylanYoung Jul 19 '20 at 21:47