Neeraj Jain
Neeraj Jain

Reputation: 7730

How do I add an existing IntelliJ Java project to git?

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?

Upvotes: 7

Views: 6981

Answers (2)

Michael
Michael

Reputation: 44090

'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'.

Upvotes: 6

Vinz243
Vinz243

Reputation: 9938

  1. Go to VCS > Import into Version Control > Create Git Repository
  2. Then go to VCS > Git > Remotes
  3. Click the + button, leave origin as-is and paste the Git URL of your repository
  4. VCS > Git > Git Pull then VCS > Git > Git Push

Upvotes: 9

Related Questions