Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 293
Julien__ Avatar asked Dec 21 '25 20:12

Julien__


1 Answers

You can use git filter-branch or BFG

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

like image 103
CodeWizard Avatar answered Dec 24 '25 10:12

CodeWizard