2

Searching for a pattern across commits containing minified javascript results in one line of context per match. Unfortunately that one line is several pages long, since it is minified javascript and not neatly broken by line breaks.

How can the context of results of git grep be limited not just by lines of context, but by total characters displayed?

Aaron Thomas
  • 5,054
  • 8
  • 43
  • 89

1 Answers1

0

Alternative approach:

If those minified javascript results are in a specific folder of your repository, you could use pathspec syntax to exclude said folder from your git grep output.

git grep solution -- :^Documentation

Looks for solution, excluding files in Documentation.

After a path matches any non-exclude pathspec, it will be run through all exclude pathspecs (magic signature: ! or its synonym ^).
If it matches, the path is ignored.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • For limiting the number of results, Git 2.38 (Q3 2022) offers now [`git grep -m`](https://stackoverflow.com/a/73028239/6309) – VonC Jul 18 '22 at 20:29