動作確認のために次のようにリポジトリを作ります。
$ mkdir aaa
$ touch aaa/.htaccess
$ touch aaa/"空 白"
$ touch aaa/$'改\n行'
$ touch aaa/$'寿司\xF0\x9F\x8D\xA3 \xF0\x9F\x8D\xA3\n\xF0\x9F\x8D\xA3'
$ git init
$ git add .
$ git commit -m first
$ git ls-files
aaa/.htaccess
"aaa/寿司? ?\n?"
"aaa/改\n行"
aaa/空 白
git filter-branch
で aaa ディレクトリを bbb に変更します。
$ git filter-branch -f --tree-filter '
[ ! -d aaa ] || {
[ -d bbb ] || mkdir bbb;
find aaa -mindepth 1 -print0 | xargs -0 -i mv -v {} bbb;
}
' HEAD
移動出来ました。
$ git ls-files
bbb/.htaccess
"bbb/寿司寿司寿司? ?\n?"
"bbb/改\n行"
bbb/空 白