Suppose your project is in a dir called project
, and you want only those commits which touch project/dirB
.
Then:
git clone project/ subproject/
cd subproject
git filter-branch --prune-empty --subdirectory-filter dirB HEAD
subproject
will now contain the git history which touches dirB
.