0.0 Getting Started with Github and Eclipse

posted Sep 6, 2016, 11:52 AM by Benjamin Nockles   [ updated Sep 11, 2017, 6:38 AM ]
Setting Up Eclipse
  1. Download the Eclipse IDE Installer. www.eclipse.org
  2. When the installer opens, you want to download "Eclipse IDE for Java Developers"
  3. After installation is complete, launch Eclipse.
  4. A welcome tab is the first thing you will see. Close this tab.
  5. Select "File...New...Java Project".
  6. Include your name in the title of the project. (So that I know who the owner of the project is when I review your work.)
About Github
Before we set up Github, I will give a short presentation explaining the concepts behind how Github works. You can find that presentation here.

Setting Up Git for Eclipse
  1. In Eclipse, right click on Project...Team...Share...
  2. In Eclipse, create a local repository in your user folder. To do this click the 'Create' button, as shown below

    A dialogue will pop up. Click 'Browse' and create a folder for this project.
     
  3. After selecting the folder for your repository, click 'Finish'.
  4. In Eclipse, Window...Show View...Other...Git/Repositories and Staging.
  5. For shortcut buttons in the toolbar, in Eclipse, go to Window...Customize Perspective, Command Groups Availability, Check Git


Creating a Brand New Git Repository

  1. Go to github.com, make an account and login. (Keep in mind the email address you use will be public)
  2. On github, click the green "New Repository" button.
  3. Give a name to your repository. Do NOT initialize it with a README file.
  4. Copy the URL of your new github repository
  5. In Eclipse, your project must be set to share (see "Setting up Git for Eclipse" above) Look in the repositories section. Expand the repository you made. Right Click Remotes...Create Remote.
  6. Change the URI. The URI will be automatically pasted for you if you have it on the clipboard.
  7. Click finish. Save this configuration.

Pushing changes from Eclipse
  1. You must have Git Staging Visible.
  2. Save changes to the files you wish to commit.
  3. Drag the files from "Unstaged Changes" to "Staged Changes"
  4. Enter a commit message.
  5. Select "Commit and Push"
  6. You will have to enter your git username and password.
Pulling Changes from Github
  1. The first time you pull changes, you will need to configure pull. Once pull is configured, you can use steps 8 onward.
  2. Find your remote (called "origin"). There is a cloud with a green arrow. This icon signifies "pull". Right click, and select "Configure Fetch".
  3. In the Ref Mappings section, click: "Advanced" (on the right)
  4. Push Ref source should be 'master'. Click "Add Spec"
  5. Click "Save specifications in 'origin' configuration.
  6. Click 'Finish'.
  7. Click 'Save'.
  8. Under Branches, right click "Remote Branches"
  9. Select "Fetch"
  10. Right click your branch ("master") under Remote Branches. Select "Merge". This will bring code from upstream onto your local repository.

Importing a Project from Github
  1. Copy the URL for your project from this website. 
  2. Go to File...Import a new project...Git...Projects from Git
  3. Select URI
  4. Paste the URI. 
  5. Select the branch to pull in. Select the "Import Existing Projects" wizard. If this does not work, try steps below in italics*.
  6. Once finished, Follow directions in "Setting Up" (above) to show repositories and staging. 
  7. If changes are made to the project, you can update those changes by using the "Pull from upstream" button.
*If this is not working, try the following:
  1. Import as a general project.
  2. Delete the project. (Right click and select delete, but do not delete to contents form the disk.)
  3. Create a new Java Project 
  4. Use the Project Folder from the git directory as the location.
  5. To connect to github:
  6. Right clcik the project. Team> Share
  7. Select the git folder. (Should already be selected.) Hit "Finish"

Homework

Please repeat this entire setup on your home computer. Please be aware that I am most familiar with Eclipse. If you choose a different IDE or different way of integrating Github, I think that is wonderful, but I may not be able to help you with some problems you may encounter if I have not seen them before.
Comments