I have a git repository which I also host on GitHub privately. I would like to split that repository into two repositories, so that some of the files would remain private, while the rest would become public. I saw some questions that asked about splitting git repositories but I did not find any that stressed the separation of public and private files, i.e. preventing sensitive information from becoming public.
As a general example, let's say I have the following git repository structure:
my-repository
| private-1.file
| public-1.file
|
|———my-private-folder
| | private-2.file
| | private-3.file
|
|———my-public-folder
| | public-2.file
| | public-3.file
|
|———my-mixed-folder
| | private-4.file
| | public-4.file
I would ideally want to split it into two git repositories:
my-private-repository
| private-1.file
|
|———my-private-folder
| | private-2.file
| | private-3.file
|
|———my-mixed-folder
| | private-4.file
and
my-public-repository
| public-1.file
|
|———my-public-folder
| | public-2.file
| | public-3.file
|
|———my-mixed-folder
| | public-4.file
My main requirement would be that my-public-repository would have no record of any of the files (importantly, their contents) that are part of my-private-repository. If some of the commits included both public and private files, I would be fine with keeping those commit messages in the log history as long as no content of the public files remain in the private repository.
Is there a straightforward way to do something like this or would this require a lot of effort?