First when you run the git filter-branch command it will give you a message saying that you shouldn't use filter-branch and should instead use filter-repo.
I don't know how to do this with filter-repo and didn't have the time to figure it out.
The `--prune-empty` flag deletes all the commits that aren't associated with the files of interest so that you don't have to do a rebase.
Finally to specify the files you want, you need to pass them to the grep command as:
```
grep -v "file1\|file2\|file3"
```
The `-v` flag inverts the match, returning all files to the `git rm` command which don't match the files you specify.
The file names must be separated with `\|` for matching multiple different tokens.
Once this command completes, you should be left with just the files of interest and the associated history.
All that's left is simply setting a new remote url and then push, i.e.
```
$ git remote set-url origin submodule.git.url
$ git push
```
**Final Important Note:** If this goes wrong you may get worried as all of your git history is wiped out.
To fix this you can use `git reflog`.
If you run `git reflog` after you mess up the `git filter-branch` you should see something like this (dummy commits from my fake repo):