Reputation: 3573
I have a folder on my computer which is a git repo.
This folder contains a file (amongst many other) named fileA
I would like to search a string str
in the content of all (or of a subset of all) the committed versions fileA
.
Is it possible?
I am not an expert in git, I use SourceTree to manage the repo.
I'm interested by any solution. For instance, a solution using GitLab ou GitHub is fine for me.
A solution via a command to execute in the terminal has been given 👍.
Is there a solution with SourceTree?
Upvotes: 2
Views: 553
Reputation: 327
For a "graphical" solution using SourceTree, I guess you will have to open a new issue with a new feature request on their Jira tracking webpage:
https://jira.atlassian.com/browse/SRCTREEWIN
Upvotes: 0
Reputation: 94417
See grep-all alias:
grep-all = !"f() { git rev-list --all | xargs git grep \"$@\"; }; f"
The alias lists all revisiosn in all branches with git rev-list --all
and runs git grep
on every revision.
To adapt it for grepping one file do
git rev-list --all | xargs -I% git --no-pager grep -F -e str % -- fileA
PS. Full disclosure: I am a contributor and reviewer in the linked repository.
Upvotes: 2