Search code examples
gitintellij-idearepository

Connect to an existing Git repository in IntelliJ IDEA


I am trying to connect an existing non-empty project to an existing non-empty repository. I have found this question which does not address this.

The title says it all, any ideas?


Solution

  • Try first in command-line, before switching to Git.

    cd /path/to/local/repository
    git remote add origin https://url/existing/remote/repository
    git fetch
    git log --decorate --oneline --graph --all --branches
    

    If you see the same history for origin/main and your local main branch, you have the right remote repository.

    Then open IntelliJ IDEA, which should detect the newly added remote origin reference.
    (Check VCS -> Git -> Remotes)