How to remove file from Git history?

后端 未结 7 875
时光说笑
时光说笑 2020-11-28 03:04

Some time ago I added info(files) that must be private. Removing from the project is not problem, but I also need to remove it from git history.

I use Gi

7条回答
  •  情歌与酒
    2020-11-28 03:28

    git-repo-filter

    git recommends to use git-filter-repo (when git filter-branch command is executed). There is a long list of why it is better than any other alternatives (https://github.com/newren/git-filter-repo#why-filter-repo-instead-of-other-alternatives), my experience is that it is very simple and very fast.

    This command removes the file from all commits in all branches:

    git filter-repo --path --invert-paths

    Multiple paths can be specified by using multiple --path parameters. You can find detailed documentation here: https://www.mankier.com/1/git-filter-repo

提交回复
热议问题