This question is often asked from the licence perspective, but my issue is more about the practical aspects.

I have some code I would like to open source, but there is in the repository some "internal" code (gitlab CI yml configuration, Maven internal repo settings, SonarQube integration, etc.)

I would like to be able to maintain two versions of the repo, with some files pushed to my internal Gitlab instance, but not to the open-source repo.

I don't think this is possible, but it would work like having a different .gitignore file for the two remotes.

How is this typically done?