Remove sensitive files and their commits from Git history

前端 未结 11 2185
借酒劲吻你
借酒劲吻你 2020-11-21 04:36

I would like to put a Git project on GitHub but it contains certain files with sensitive data (usernames and passwords, like /config/deploy.rb for capistrano).

I kno

11条回答
  •  说谎
    说谎 (楼主)
    2020-11-21 05:20

    You can use git forget-blob.

    The usage is pretty simple git forget-blob file-to-forget. You can get more info here

    https://ownyourbits.com/2017/01/18/completely-remove-a-file-from-a-git-repository-with-git-forget-blob/

    It will disappear from all the commits in your history, reflog, tags and so on

    I run into the same problem every now and then, and everytime I have to come back to this post and others, that's why I automated the process.

    Credits to contributors from Stack Overflow that allowed me to put this together

提交回复
热议问题