Github is an crawly repository to share your source code. Although in that location are numerous tutorials discussing how to utilise git and eclipse, I got stuck again today while trying to upload an existing eclipse project to github. This tutorial walks thus through all the steps from signing up for github to uploading an eclipse project to the site!

Please notation that the focus of this tutorial is the mere upload of source lawmaking and non any of the more sophisticated features git and github offer.

The post-obit steps volition be discussed in this tutorial:

  1. Sign Up for github
  2. Installing EGit
  3. Create a DSA Primal in Eclipse
  4. Register DSA Key with github
  5. Create Repository on github
  6. Import github Repository into eclipse
  7. Link Eclipse Project with github Repository
  8. Uploading Project Sources to github

Step 1: Sign Up for github

That's the easiest part, but become to https://github.com/ and register!

Step two: Installing EGit

You will need to install the git plugin for eclipse, EGit, in order to upload code from eclipse projects.

  • In eclipse, go to Assistance / Install New Software

  • Open the eclipse Indigo repository

  • Select Collaboration / Eclipse EGit

  • Click [Side by side]
  • JGit should have been selected for yous automatically

  • Click [Side by side] and ostend the licence agreement
  • Restart eclipse and the EGit plugin should be installed

Footstep 3: Create a DSA Key in Eclipse

In club to be able to upload source code to github, yous need to define a secure key, which must be known both to your local eclipse installation besides as the github service. Luckily, eclipse provides all the tooling necessary to generate the advisable key.

  • Open Menu Window / Preferences
  • In the preferences, get to General / Network Connections / SSH2
  • On the SSH2 page, open the tab 'Central Direction'


  • Click on [Generate DSA Key …]
  • At the bottom of the folio, enter a passphrase of your choosing


  • Click [Save Private Key …] (what's going on with these three dots in the button captions … strange)
  • Save the cardinal at a location of your choosing (best in the location specified as your SSH2 dwelling house on under the tab Full general)

Footstep iv: Annals DSA Key with github

  • Open the file you accept saved in the previous step with a text editor (east.one thousand. Notepad on windows)
  • Select the contents of the file (Ctrl + A) and copy the complete text
  • Go to the github website (https://github.com) and login
  • On the top right of the screen, click on 'Account Settings'

  • On the left hand side of the account settings, click on 'SSH Keys'

  • Click on [Add SSH key]
  • Provide an appropriate championship for your key (e.g. 'EGit i' ?)
  • Paste the contents from the text file containing your DSA key into the text box 'Fundamental'

  • Click [Add Key] at the bottom of the form

Step 5: Create Repository on github

In order to upload source lawmaking from a projection in eclipse to github, you lot will need to create a github repository.

  • Go to github homepage (https://github.com/) and log in
  • At the top right corner, click on 'Create a New Repo'

  • Chose a repository name and clarification to your liking and click [Create Repository]

Step 6: Import github Repository into eclipse

Before y'all can link an existing eclipse project to a github repository, you lot must import the repository you have created on github commencement. For this:

  • In eclipse, open Bill of fare / Window / Show View / Other …

  • Select Git / Git Repositories and click [Ok]

  • You might see a warning message such every bit the one show below (even setting the surroundings variable did non help me to get rid of the message, but everything seems to be working okay) – you tin ostend with [Ok]

  • Y'all should take a new view 'Git Repositories now'
  • Click on 'Clone a Git repository' within the new view

  • Now go back to https://github.com and to your newly created github repository
  • Under your repository description, you can get the URI for your project. Re-create the text starting with 'git@' (brand sure that SSH is selected)


  • Become back to eclipse. You tin paste the URI you have just copied into the field 'URI'
  • Further select equally Protocol 'ssh'
  • Click [Finish]


  • If asked to select a branch, select the 'chief' co-operative


Git (in divergence to subversion) allows storing a full diddled repository on your local machine rather than just a local re-create of the files. This requires to store all source you want to synchronize with git at least twice on your local car: one copy will be stored in the clone of the remote git repository and some other one will exist stored in your eclipse projection.

Hence, when you shut the git repository from github, you should define a repository location, which lies exterior the eclipse project you want to upload:

  • Select one such location and click [End]


  • Now yous should take 1 'Git Repository'


Stride 7: Link Eclipse Projection with github Repository

Afterwards you accept created a local clone of the repository from github, you can link the eclipse project you would similar to upload to this local repository.

  • Right click your eclipse projection and select Team / Share Project …
  • Select 'Git' as Repository Blazon

  • Select under 'Repository' the repository you have cloned in the previous footstep and click [Finish]


Stride eight: Uploading Project Sources to github

After you have linked your project with the local clone of the github repository, you can 'Commit' all the source files in your existing projection to this repository. After y'all have committed the files to your local repository, you can 'Push' them to the github repository.

  • Correct click your project and select Squad / Commit … from the popup carte


  • Write a beautiful commit message and click [Commit]


  • In the 'Git Repositories' view, open <your repository> / Remotes / origin
  • Right click on the second icon (with the red arrow) and select 'Push button'


  • You should receive the results of the push, click [Ok] to ostend


  • You can now go to github and your projection sources should be displayed in your repository:


(hmm, did information technology actually took 2 hrs to become this washed …)

References

Git with Eclipse (EGit) – Tutorial (vogolla.com)

Getting Started with Git, EGit, Eclipse, and GitHub: Version Control for R Projects

git push rejected (stackoverflow.com)

A Curt Tutorial on Eclipse/EGit/GitHub

Tutorial: Using the EGit Eclipse Plugin with GitHub