I am using the answer to this question to strip a clone of a repository to a list of files I want to keep in a spin off of this project. Say I want to strip all but directory src/main
and its sub-directories. Because I will have multiple files and directories, I use --index-filter
instead of --subdirectory-filter
.
I thought the following should work:
git filter-branch --index-filter "git rm -r -f --cached --ignore-unmatch ↩
src/!(main)" --prune-empty -- --all
But all I get is
-bash: !: event not found
I tried all sorts of different paths instead of src/!(main)
. I always get exactly that error message. It seems to be a bash problem, because that line also doesn't enter my command line history?
That is to say, if I have top level files A
, and B
, and subdirectory C/D
, how can I remove all but these three things?