Today, the goal - is to push a simple Java Project (created in Eclipse) into GitHub.
I already created a quick, simple Java Project in Eclipse.
- My Eclipse Workspace Directory = C:\Users\gradney\workspace\Git
- Name of my Java Project = "MyFirstApp"
As you can see, I don't really have any code in my project. I only have one Java class with an empty main(). First, I want to see if I can push my Java project into GitHub before I start coding like crazy and having no where to store a controlled version of my coding. If I have no place to store my code, then one day I might lose my code and have to start all over. Ugh, I've done this before and it REALLY sucks. Hence, why I'm blogging about using GitHub.
So, now that I have a Java project, how do I push this into my HeadFirstJava repo in GitHub?
Let's see if sharing this project in Eclipse to my local Git repo will trigger an automatic update in my GitHub Client App.
-------------------------------------------------------------------------------------------
Click on "Add an existing local Git repository".
See a dialog display with your Git root directory and listing repositories existing in your local Git directory.
Check the Git repository to add, and click Finish.
In Eclipse within the Navigator view (or Package Explorer view), I right-click on the project "MyFirstApp" and select "Team" > "Share Project...".
In Eclipse's "Configure Git Repository" window, I select my "HeadFirstJava" repository from the drop-down option and see how pretty much everything is already set to go.
- Project = MyFirstApp (checked)
- Current Location = C:/Users/gradney/workspace/Git/MyFirstApp
- Target Location = C:/Users/gradney/git/HeadFirstJava/MyFirstApp
I now see question marks on my folder and files that are shared into my Git repo.
Next, I right-click on the project "MyFirstApp" and select "Team" > "Commit".
I add a Commit message, check the file(s) I would like to commit (which is "MyFirstApp.java") and I click "Commit".
*I am NOT clicking on "Commit and Push" because I had issues where my Git repo was not pushing my files up to GitHub. Hence, why I'm going to push my files using the GitHub Client App. See my first blog for my struggles.
**(Oct 16, 2014) Using Eclipse IDE Luna, I was able to setup my Git connection to GitHub without issues and able to click on "Commit and Push" without issues. :) Seems like Eclipse Team fixed this.
Notice the question marks on the folder/file icons have disappeared. This must mean my files are committed to my local Git.
If we open up the GitHub Client App, we see that I have my project added and ready to commit (if I haven't already committed in Eclipse).
Once we already commit our files in Eclipse to the local Git repository, GitHub Client App automatically reflects this and provides additional options (such as reverting, sync'ing to GitHub, etc.).
I want to "push" my project up to GitHub which means I want to publish everything locally in my HeadFirstJava repo to my online repo in GitHub called HeadFirstJava. This is basically sync'ing my local and my online repos. So, I click on the "sync" button.
Then, let's go to my GitHub and see if we achieved our goal for today - adding a Java Project into GitHub.
YES!!! Success!! MyFirstApp is stored in my GitHub repo called HeadFirstJava.
And I can navigate within the project in GitHub to that I uploaded the right code for MyFirstApp project. EXCELLENT!
No comments:
Post a Comment