Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I add my intelliJ project to an already existing Github repository?

I already have a Github repository, but I need to add my actual project to the repository. How should I do this with IntelliJ? The project should be versioned of course.

like image 413
Ralph Avatar asked Nov 22 '16 12:11

Ralph


People also ask

How do I add an IntelliJ project to an existing GitHub repository?

Select the files you want to add to Git or the entire changelist and press Ctrl+Alt+A or choose Add to VCS from the context menu. You can also add files to your local Git repository from the Project tool window: select the files you want to add, and press Ctrl+Alt+A or choose Git | Add from the context menu.

How do I link my GitHub to IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Version Control | GitHub. Select Log In via GitHub. Enter your GitHub credentials in the browser window that opens. If you have two-factor authentication enabled, you will be asked to enter a code that will be sent to you by SMS or through the mobile application.


3 Answers

IntelliJ will automatically discover and "add" your git repository as soon as it finds a .git directory in the project root directory. The steps you have to run depend on whether you already have a Git repository initialized for your project or not. If not, first open a terminal (e.g. by pressing ALT+F12 for opening a terminal window in IntelliJ) and run

git init

Afterwards (or if you already have a git repository in your project) you can "connect" this repository to your project on Github with

git remote add origin GIT_URL_ON_GITHUB

IntelliJ will then "find" your repository and offer git support.

like image 151
Michael Lihs Avatar answered Oct 12 '22 01:10

Michael Lihs


I don't know how familiar you are with IDEA hotkeys, therefore the instruction using top navigation bar: VCS -> Enable Version Control Integration -> Select your version control system (Git in your case) -> Wait for IDEA to update project -> Your project hierarchy now shows all files in brown color -> Select the files you want to commit -> Right click and select Git-Add -> In the bottom navigation bar you should also see "9: Version Control" -> Click on this button -> The window with uncommited changes appears and recently added files are green-colored -> Select the files you want to commit -> Right click on the files -> Select "Commit Changes" from the popup menu -> Specify commit message -> Hover over the "Commit" button -> Press "Commit and Push" -> In the dialog you can specify the master branch of your origin repo on Github -> Press Push after that -> You're done.

Feel free to ask if I missed smth. out.

like image 30
Arthur Eirich Avatar answered Oct 12 '22 00:10

Arthur Eirich


You can initialize the local directory of your project as a Git repository with the following steps: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

Then, if you have Git plugin for IntelliJ, go to version controll, commit changes, and then you can push.

like image 28
Manuel S. Avatar answered Oct 12 '22 01:10

Manuel S.