By default, Select-String's -Pattern parameter accepts regexes (regular expressions), which allow you to describe desired matches using sophisticated rules:
git log -5 --no-merges master |
Select-String -Pattern '^commit |^\s+Precommit-'
^commit matches string commit, follwed by a space, at the start of a line (^)
| is an alternation, meaning that the subexpression on either side is allowed to match.
^\s+Precommit- matches string Precommit-, preceded by one or more (+) whitespace characters (\s) at the start of the line (^).
This regex101.com page not you to experiment with the regex interactively (the panel on the right side also contains an explanation).
Note: Select-String, like PowerShell in general, is case-insensitive by default. You can request case-sensitive matching with the -CaseSensitive switch.