How to add an IntelliJ project to GitHub

Although the GitHub docs contains good info on how to add an existing GitHub project to your local machine, how to add an existing (unversioned) project from your local machine to GitHub was a little less clear to me. Here are the steps I use.

From IntelliJ

  • Select ‘VCS’ menu -> Import in Version Control -> Share project on GitHub.
  • You may be prompted for you GitHub, or IntelliJ Master, password
  • Select the files to commit

In the latest version (v13) of IntelliJ, you will then be prompted for which files you wish to include as part of the initial commit. Obviously deselect anything in the target (aka classes) folder. I also exclude the .idea folder. Click OK and you new project and files should now be available via GitHub!

In older versions of IntelliJ, this step (somewhat strangely) created the project with just the readme. Follow the the next step to add the other files.

To add more files:

  • Select files to add
  • Right click -> Git -> Add
  • Commit files (Ctrl-K or VCS -> Git -> Commit) [Commit & push easier, but can also just Commit]
  • If files not pushed in step above, VCS -> Git -> Push

From command line

I think the following steps do the same thing from the command line, but it has been a while since I used them:

  • Create a new repository
  • cd to your project directory e.g. cd projects/newproject
  • Run the following git commands
    • git init
    • git add .
    • 
git commit -m “Initial commit”
    • git remote add origin https://github.com/username/projectname.git
    • Notes:
      • I think: git remote add origin git@github.com:username/projectname.git does the same thing.
      • The ‘origin’ name is arbitrary (As with branch naming, remote alias names are arbitrary – just as ‘master’ has no special meaning but is widely used because git init sets it up by default, ‘origin’ is often used as a remote name because git clone sets it up by default as the cloned-from URL. You can really name it just about anything.)
    • git push -u origin master
    • (Note to remove a remote again: git remote rm origin)

Resources

http://stackoverflow.com/questions/2866872/how-to-upload-fresh-code-at-github

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


2 − = one



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close