If you accidently add sensitive information to your repository like password and detailed configurations, you should use follow command to remove them from the repository. More than that, you should change sensitive information for remote machines with your colleagues. Substitute names of other files you want with below text within background color is gray. 如果你不小心放入敏感資訊到你的Git公開軟體專案,例如遠端機器密碼和資料庫連線設定,請使用以下指令將其移除,並改變敏感資訊的內容及通知你合作開發的夥伴。依據你所需,請替換指令中的灰色背景文字,以下是範例:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch .DS_store config/database.yml config/secrets.yml' --prune-empty --tag-name-filter cat -- --all
The command will erase the files you specified in all commits.
本篇內容來自GitHub.com的Remove sensitive data文章