How to search a block of code as a whole

Viewed 157

My files has

.settings {
}


.field {
    margin-bottom: 1em;
}

I want to know when

.settings {
}

was formed.

I know if I want to search one line of code, I do git log -S".settings {".

But here I want to search

.settings {
}

as a whole, I tried

git log -S".settings {\r}" confirm.less.css
git log -S".settings {\n}" confirm.less.css
git log -S".settings {\r\n}" confirm.less.css

but all retrun nothing.

How do I search a block of code as a whole containg new line characters?

2 Answers

Try

git log -L '/^.settings {/,+1':path/to/it

That'll get you the whole history of updates to that range, but the oldest of them will be what you want.

Related