简体   繁体   English

如何搜索我的整个git repo的提交历史记录以进行字符串更改?

[英]How can I search my ENTIRE git repo's commit history for a string change?

I have a website/repo. 我有一个网站/回购。

Part of my website says: 我网站的一部分说:

"Powered by https://myotherwebsite.com/ '" “由https://myotherwebsite.com/提供支持”

at some point, some troll I had working on the website switched it to say: 在某些时候,我在网站上工作的一些巨魔改变它说:

"Powered by https://theirwebsite.com " “由https://theirwebsite.com提供支持”

How can I search the entire repo history to the commit where this change was made. 如何将整个仓库历史记录搜索到进行此更改的提交。

There have been A LOT of commits/branches over the years. 多年来一直有很多提交/分支机构。

If you can ignore dead branches and assume that all relevant code is reachable from your most recent master version, I'd recommend using the -S option of git log : 如果您可以忽略死分支并假设可以从最新的主版本访问所有相关代码,我建议使用git log的-S选项:

git log -S "theirwebsite"

Take a look at the doc , and maybe consider using regexp search if your actual need is or becomes more complex than what you described here. 看看文档 ,如果你的实际需要是或者比你在这里描述的更复杂,可以考虑使用regexp搜索。


Even better : with --all you can search your entire repo (thanks to j6t for the trick!) 更好的是 :使用--all你可以搜索你的整个仓库 (感谢j6t的诀窍!)

git log --all -S "theirwebsite"

(and, as noted by vfalcao, consider using the --name-only option here to list files where this change happened.) (并且,如vfalcao所述,请考虑在此处使用--name-only选项列出发生此更改的文件。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM