1

I would like to extract the diff of all commits that pass a certain regex in their messages.

For example:

  • Commit 4: "JIRA-12 Deleted Something" diff4
  • Commit 3: "JIRA-13 Modified something" diff3
  • Commit 2: "JIRA-13 Added Another thing" diff2
  • Commit 1: "JIRA-12 Added something" diff1

I would like to be able to get the diff for all the commit that have JIRA-12 in their messages.

I imagine I should type something like git diff --message "*JIRA-12*" that would give me diff1 + diff2.

Is there a Git command that does that? Or are there other means to do that?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65

1 Answers1

1

git log --grep <REGEX HERE> -p

The --grep option allows you to find only the commits that match the given regex.

To get the diff for each of the commits add the -p or --patch option. This shows the changes that were included in each of the commits.

I believe that this will get you what you are looking for.

Schleis
  • 41,516
  • 7
  • 68
  • 87