列出所有删除任何文件的git提交

发布于 2025-02-10 20:10:53 字数 254 浏览 2 评论 0原文

问题

如何列出删除存储库中任何文件的所有提交? (不是一个特定的文件,而是所有删除任何内容的提交)。

上下文

我们有一个多年历史的存储库,我们计划将该项目释放为开源。

我们想检查是否没有将凭据过滤到公众中。

对于跟踪的文件,我们可以轻松地看到其中的内容,以及过去是否有秘密。

但是我们想看看是否有任何可能披露秘密的文件。”

我们只想列出跟踪和后来删除的所有文件,以查看历史记录的那些部分。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情绪少女 2025-02-17 20:10:53

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

茶底世界 2025-02-17 20:10:53

旁注:

如果您知道在差异中寻找什么 - 例如,如果您知道应该查找包含字符串的文件,例如aws_secret_key = ...api_key =。 ..,或者如果您知道可能出现在上述文件中的秘密的值 - 您可以使用-G选项:

# will list all commits where the string 'AWS_SECRET_KEY' appears in the diff :
git log --name-status -G "AWS_SECRET_KEY" --all

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=... or API_KEY=..., or if you know the value of the secrets that could appear in said files -- you can use the -G option :

# will list all commits where the string 'AWS_SECRET_KEY' appears in the diff :
git log --name-status -G "AWS_SECRET_KEY" --all
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文