列出所有删除任何文件的git提交
问题
如何列出删除存储库中任何文件的所有提交? (不是一个特定的文件,而是所有删除任何内容的提交)。
上下文
我们有一个多年历史的存储库,我们计划将该项目释放为开源。
我们想检查是否没有将凭据过滤到公众中。
对于跟踪的文件,我们可以轻松地看到其中的内容,以及过去是否有秘密。
但是我们想看看是否有任何可能披露秘密的文件。”
我们只想列出跟踪和后来删除的所有文件,以查看历史记录的那些部分。
Question
How can I list all the commits that delete any file in the repo? (not a specific file, but all the commits that delete anything).
Context
We have a multiple-years-old repo and we plan to release the project as open-source.
We want to check that no credentials are filtered into the public.
For the tracked files we can easily see what is in there and if in the past there was anything secret.
But we want to see if "at any time, there was any file that could potentially disclose secrets."
We want just to list all the files that were tracked and later deleted, to review those portions of the history.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
git log -diff-filter = d-summary
参见在git存储库中查找并还原已删除的文件
如果您不希望将其删除的所有提交所删除的所有信息,则只需在其中添加GREP删除即可。
git log -diff-filter = d-summary | GREP DELETE
git log --diff-filter=D --summary
See Find and restore a deleted file in a Git repository
If you don't want all the information about which commit they were removed in, you can just add a grep delete in there.
git log --diff-filter=D --summary | grep delete
旁注:
如果您知道在差异中寻找什么 - 例如,如果您知道应该查找包含字符串的文件,例如
aws_secret_key = ...
或api_key =。 ..
,或者如果您知道可能出现在上述文件中的秘密的值 - 您可以使用-G
选项:a side note :
if you know what to look for in the diffs -- for example, if you know you should look for files which contain strings like
AWS_SECRET_KEY=...
orAPI_KEY=...
, or if you know the value of the secrets that could appear in said files -- you can use the-G
option :