Reputation: 139
I currently use git log -G "XYZ" -p
to search for past changes on certain things, like classes, but often come into the problem where the diff is very large and it makes it difficult to find the actual line where my search term was changed. Is there a way to limit the output to only that line or only the few lines around it?
Solution: git grep xyz $(git rev-list --all --max-count=5)
--max-count is optional (I needed it to avoid error Argument list too long
)
Upvotes: 2
Views: 1133
Reputation:
you can do grep like git log -G "XYZ" -p | grep pattern
, if its window use findstr..
instead of using --max-count, --since and --until will be better if you know appr. time period you want to search
git grep xyz $(git rev-list --since="2016-11-20" --until="2016-11-21" --all)
however best way will be to use in 2 part. 1) identify commit,file name and count using below command
1) git grep -c xyz $(git rev-list --all)
pass this commit number to below command to get exact issue
2) git grep xyz 718dcc690d8e99fd399f21fd71c86b1b8812a53d
Upvotes: 1