Find substring in recent commit messages

1

I'm looking for a substring in the most recent commits in my repository.

I use the command git log -n1 --grep='${subString}' .

But using the -n flag I will only get the last commit, which is technically the most recent. Ex:

commit 1a1a
Author: Gabriel Hardoim
Date: 2018-08-20 13:30:40

       Esse commit tem a substring

But it can, and probably will, happen that there is more than one commit made recently, which makes the -n flag inefficient.

Ex:

commit 2b2b
Author: Gabriel Hardoim
Date: 2018-08-20 13:40:02

       Esse commit não tem

commit 1a1a                             //Nesse caso, esse é o commit que eu quero.
Author: Gabriel Hardoim
Date: 2018-08-20 13:30:40 

       Esse commit tem a substring

There are still the most common cases, but there are several commits with the substring I'm looking for.

Ex:

commit 2b2b
Author: Gabriel Hardoim
Date: 2018-08-20 13:40:02

       Esse commit não tem

commit 1a1a                             //Nesse caso, esse ainda é o commit que eu quero.
Author: Gabriel Hardoim
Date: 2018-08-20 13:30:40 

       Esse commit tem a substring

commit 3c3c
Author: Gabriel Hardoim
Date: 2018-08-20 13:20:11

       Esse commit também tem a substring

commit 4d4d                             
Author: Gabriel Hardoim
Date: 2018-08-20 13:13:05 

       Esse commit também não tem

Considering that the commits went to the remote repository by the same git push command, what can I do to find a substring in the most recent commit message?

    
asked by anonymous 20.08.2018 / 19:08

1 answer

2

You can use the terminal / shell / linux grep instead.

git log | grep --context=4 "TEXTO"

A simple git log in conjunction with linux grep, asking to "group" the results in 4 lines backwards.

In my local test, I displayed three commits whose descriptive messages had the searched word.

    
20.08.2018 / 21:14