Skip to content

Instantly share code, notes, and snippets.

@huobazi
Created September 13, 2020 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huobazi/d8953ad66d16a24bae9f37dbe012ff52 to your computer and use it in GitHub Desktop.
Save huobazi/d8953ad66d16a24bae9f37dbe012ff52 to your computer and use it in GitHub Desktop.
Remove password from git commit history

在github上传了带密码的文件的删除方法

在 GitHub上Push了带密码的文件,就算删掉文件,commit 历史还是残留的。

怎样删除commit历史呢?

方法:

使用 git filter-branch 可以替换 commit 历史,然后 --force push。

$ git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch .env' --prune-empty --tag-name-filter cat -- --all
$ git push origin master --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment