git - limit characters in result of git grep

Viewed 150

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?

1 Answers

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.

Related