2

The :/ syntaxallows you to match commits using regular expressions. E.g., to create a fixup commit for an earlier commit that contains the string 'Add widget', you can write:

git commit --fixup ':/Add widget'

Is there way to apply modifiers such as ^ or ~ to the :/ expression? I've tried the obvious syntax...

git show ':/Add widget^'

Which doesn't work:

fatal: ambiguous argument ':/widget^': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

(And git show ':/Add widget^' -- results in fatal: bad revision ':/Add widget^').

larsks
  • 277,717
  • 41
  • 399
  • 399

1 Answers1

6

Use the anchored search, '@^{/Add widget}^' or do the substitution yourself with $(git rev-parse :/Add\ widget)^

jthill
  • 55,082
  • 5
  • 77
  • 137