How to add existing IntelliJ project to Git/GitHub with history?

Solution for How to add existing IntelliJ project to Git/GitHub with history?
is Given Below:

I’m fairly new to Git. I recently started a project in Java using IntelliJ, not realizing that I should have connected to Git/GitHub before writing code. I now want to connect the project to Git/GitHub, but with previous versions of the project committed (this is the part I’m having trouble with). I have access to the project history in IntelliJ, if that helps. How can this be done?

My full understanding is that you want to go back to the code when you first started your project. If my understanding is correct, you can check it out here. https://www.jetbrains.com/help/idea/local-history.html#restore-changes-from-local-history