It looks like filter-branch does what I want:
git filter-branch --tree-filter \ 'mkdir subdir; \ find -maxdepth 1 \ -not -name . \ -not -name .git \ -not -name subdir \ -print0 \ | xargs -0 -I{} mv {} subdir' \ -d /tmp/whatever -- --all
The -d /tmp/whatever is only intended to execute commands on the tmpfs file system, so there is no IO group with a record.
(In rare cases, /tmp will not mount as tmpfs. You can check with mount | grep tmp .)
source share