Sublime Forum

Find inside a commit


Let say I’m looking at a commit, how can I search for a word inside that specific commit?

Normally I would do:

git show

and search with /



Hey @FrancoisGervais, welcome to the community!
You can hit control-f, type commit: and the commit hash and content: with your search text. You can also type path: or file: to make your search more specific.

1 Like


That’s perfect,

Any way I can reference the current commit I’m on? I would have though commit:HEAD but it doesn’t seem to work.



One way to do this would be to use the context menu to copy the commit hash of the commit that you’re viewing (for example from the “three dots” menu that appears in the commit details box) so that you can paste it into the commit: field.

It might be possible to craft a key binding that would do that in a single step; I’m not sure. There’s a variable that expands out to the current commit hash, so I would think that you could craft an argument to open the find panel with that pre-populated.

There may also just be such a key already that I’m not aware of at the moment. :slight_smile:



Below would be how, but I’m not sure how useful it’ll end up being. The contents: section will only search the changed text in the commit (not near/within-hunk or anywhere else in the file) and worst of all, the search results will include the entire file changes, not just the matching hunk(s).

Put in File.sublime-menu and/or Diff Context.sublime-menu for right-click support (it will be available in the working copy, but won’t work correctly due to the missing commit hash):

        "caption": "Find changes in File...",
        "command": "search", "args": { "query": "path:\"$path\" and commit:$commit and contents:search" }


Thank you all for the replies