The simplest solution is to leave only history: just git mv all your files into a subdirectory, commit this change and continue your life.
If you really want to pretend like you've been working in a subdirectory all the time, the least complicated way is to use something like:
git filter-branch --tree-filter "mkdir SUBDIR && bash -c 'git mv -k {,.[!.],..[!.]}* SUBDIR/'"
Replace SUBDIR with the name of the target subdirectory.
source share