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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

For limiting the number of results, Git 2.38 (Q3 2022) offers now git grep -m

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.