Forrest logo
back to the git tool

git-log:tldr:4b13b

git-log: Show only commits whose messages include a given string (case-insensitively).
$ git log -i --grep ${search_string}
try on your machine

The command git log -i --grep ${search_string} is used to search the commit history in a Git repository for a specific string. Let's break down the command:

  • git log: This command displays the commit history of the repository. By default, it shows all the commits from the most recent to the oldest.

  • -i: This option makes the search case-insensitive. It means that the search will ignore the case of the characters when looking for a match.

  • --grep: This option is used to filter the commit messages based on a pattern or string provided. It allows you to search for commits that contain a specific string or pattern.

  • ${search_string}: This is the placeholder for the string you want to search for in the commit messages. You should replace ${search_string} with the actual string you want to search for, without the curly braces.

So, when you execute the command git log -i --grep ${search_string}, Git will display the commit history and only show the commits whose messages contain the provided string ${search_string}. Additionally, the search will be case-insensitive, meaning it won't distinguish between uppercase and lowercase letters when looking for a match.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool