Remove a directory from all previous commits

前端 未结 2 1709
忘掉有多难
忘掉有多难 2021-01-30 23:56

Git Repo, there is a folder ABC with three files, all having spaces in the name file - 1.ext, file - 2.ext, and file - 3.ext.

2条回答
  •  逝去的感伤
    2021-01-31 00:33

    Instead of using --index-filter, try with --tree-filter:

    --tree-filter 
        This is the filter for rewriting the tree and its contents. The argument is
        evaluated in shell with the working directory set to the root of the
        checked out tree. The new tree is then used as-is
        (new files are auto-added, disappeared files are auto-removed -
        neither .gitignore files nor any other ignore rules HAVE ANY EFFECT!).
    

    The commandline:

    git filter-branch --tree-filter 'rm -rf path/to/ABC' \
      --prune-empty --tag-name-filter cat -- --all
    

提交回复
热议问题