Reputation: 21
Scenario: I have multiple files on GitHub under multiple branches (e.g Master / Dev / UAT etc.), in which I want to search and replace a string (e.g. "Connection").
Issue: Once the string has been changed (e.g. "Connection Oracle" to "Connection MySQL"), then the earlier string "Connection Oracle" is still stored in the git history.
How can I list all the files which have a particular string (e.g "Connection") in the git history.
Upvotes: 1
Views: 2026
Reputation: 38161
There is nice tool git grep
So just do:
git grep --files-with-matches Connection
IMO, for your case, it would be bast to apply this on each branch you need to update. Searching whole history will flood you with useless information.
If you need to update master
it is not wise to update branches which will be merged to master
in later time, since it will introduce unneeded merge conflicts.
Upvotes: 1
Reputation: 349
Maybe git log -SConnection
but I think you be on the branch that you want to search on.
Here the doc about -S option for git log
-S Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.
Upvotes: 1
Reputation:
You can use git grep command i.e. git grep Connection $(git rev-list --all )
Please go through answer mentioned in below link
How to grep (search) committed code in the git history?
Upvotes: 1