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