Git:从历史记录中删除文件夹,但一位作者除外

时间:2016-11-20 12:39:53

标签: git git-filter-branch git-rewrite-history

如何从历史记录中的每个提交中删除文件夹,而不是特定作者的文件夹?

示例: 作者Bapp/都修改了文件夹B。我需要删除(在历史记录中)A对文件夹的所有贡献,而不是def order(lst): if lst == [] or len(lst) == 1: return lst elif lst[0] < order(lst[1:])[0] or lst[0] == order(lst[1:])[0]: return [lst[0]] + order(lst[1:]) return order(lst[1:]) + [lst[0]] 的贡献。

1 个答案:

答案 0 :(得分:3)

您可以使用BFS的git filter-branch

git filter-branch

https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History

git filter-branch --commit-filter '
    if [ "$GIT_COMMITTER_NAME" = "<commiter A>" ];
    then
            // remove any required data and re-commit it again
            git commit-tree "$@";
    else
            git commit-tree "$@";
    fi' HEAD `

BFG

https://rtyley.github.io/bfg-repo-cleaner/

enter image description here

相关问题