【问题标题】:How to remove all traces of a single file in git [duplicate]如何在git中删除单个文件的所有痕迹[重复]
【发布时间】:2014-02-08 09:11:53
【问题描述】:

我最近注意到我在 git 中的版本控制下有一个包含敏感信息的文件。我现在已将此文件添加到我的 .gitignore 列表中,但是如何在不触及任何其他内容的情况下从我的提交历史记录中删除所有提及它的内容?即,我不想只删除我的 .git 目录。

【问题讨论】:

    标签: git


    【解决方案1】:

    在 GitHub 帮助网站上试用此指南:https://help.github.com/articles/remove-sensitive-data

    具体来说:

    git filter-branch --force --index-filter \
      'git rm --cached --ignore-unmatch Rakefile' \
      --prune-empty --tag-name-filter cat -- --all
    

    【讨论】:

    • 这会删除.git/文件夹元数据中敏感文件的任何痕迹吗?
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 2011-09-22
      • 1970-01-01
      • 2016-04-27
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 2019-02-10
      相关资源
      最近更新 更多