Remove sensitive files and their commits from Git history

前端 未结 11 2225
借酒劲吻你
借酒劲吻你 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:12

    Use filter-branch:

    git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *file_path_relative_to_git_repo*' --prune-empty --tag-name-filter cat -- --all
    
    git push origin *branch_name* -f
    

提交回复
热议问题