git rev-list --reverse
series
-- repo1/project1/src/ \
| xargs -I@ git format-patch --stdout @^! >mystuff.patch
will spit the commits in series that affect that subdirectory into mystuff.patch
Then,
cat >mystuff.sed <<\EOD
/^(From [0-9a-f]{40}|diff --git )/!{H;$!d}
x
/^From /b
${h;s,.*--,--,;x}
\,^diff[^\n]* [ab]/repo1/project1/src/,!{$!d;x;b}
${p;x}
EOD
and
sed -Ef mystuff.sed mystuff.patch >justmystuff.patch
will strip out all the hunks outside that directory. You can apply with
git am justmystuff.patch
with -p
n
and --directory=new/path/to
as desired.
(edit: EOD --> \EOD so the cat above doesn't try to substitute)