This question is similar to this one for Eclipse but with a different IDE.
How can I add my pre-existing Java to git in IntelliJ IDEA?
Current State:
I could check out the new repository, copy the contents of my project to this directory and just push to master, but is there a simpler way within the IDE that avoids changing the location of the project?
Do one of the following: To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu. To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push from the list of actions.
In the command line, navigate to the root directory of your project. Initialize the local directory as a Git repository. To create a repository for your project on GitHub, use the gh repo create subcommand. When prompted, select Push an existing local repository to GitHub and enter the desired name for your repository.
VCS > Import into Version Control > Create Git Repository
VCS > Git > Remotes
+
button, leave origin as-is and paste the Git URL of your repositoryVCS > Git > Git Pull
then VCS > Git > Git Push
'VCS' on the menu bar > 'Import into Version Control' > 'Create Git repository...'
To hopefully somewhat future-proof this answer in case the location moves, you can use:
CtrlShiftA (or CommandShiftA on a Mac) to open the action search dialog and search for 'create git'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With