0

I just got a directive to revert a bunch of committed code. The good news is that all commit's have a reference string in them, something like:

ABC-1556
ABC-1616
ABC-4818
ABC-5919

This commend will give me one of them, how do I modify the grep commend to find them all?

git log --pretty=oneline --abbrev-commit --grep='ABC-1556'
Sam Carleton
  • 1,339
  • 7
  • 23
  • 45

2 Answers2

1

You could put all your reference strings into a file (say, patterns), and then use xargs to run the git log command for each string:

xargs -iPATTERN git log --pretty=oneline --abbrev-commit --grep="PATTERN" < patterns

If it's just a small number of patterns you could combine them on the command line like this:

git log --pretty=oneline --abbrev-commit -E --grep="ABC-1556|ABC-1616|ABC-4818|ABC-5919"
larsks
  • 277,717
  • 41
  • 399
  • 399
0

I had tried this, but it didn't work:

git log --pretty=oneline --abbrev-commit --grep='ABC-1556|ABC-1616'

But I discovered this did:

git log --pretty=oneline --abbrev-commit --grep=ABC-1556 --grep=ABC-1616

Problem solved!

Sam Carleton
  • 1,339
  • 7
  • 23
  • 45