Julien__ Julien__ - 19 days ago 6
Git Question

Git: remove folder from history except for one author

How can I remove a folder from every commit in the history but those of a particular author ?

Example :
Authors

A
and
B
both modified the folder
app/
. I need to remove (in the history) every contribution of
B
to the folder but not those of
A
.

Answer

You can use git filter-branch of BFS

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