Prerequisites
- An Eclipse project with at least 1 Java file (to avoid an empty src folder)
- An SSH key shared with GitHub
- An empty GitHub repository
Show Eclipse views
In Eclipse, open the Git Repositories and Git Staging views.
- Select
Window -> Show View -> Other
Window menu - Select
Git -> Git Repositories / Git Staging
Show View dialog
Clone GitHub repository
- Open the repository on GitHub.com.
- Under the Quick setup section, copy the SSH URI. It might be necessary to click the SSH button. The SSH URI begins with
git@github.com:
. GitHub SSH URI - In the Eclipse Git Repositories view, select the Clone button. The Clone button has a green arrow and a tooltip that reads “Clone a Git Repository and add the clone to this view”. Clone button
- In the Clone Git Repository dialog, Eclipse usually reads the URI from the clipboard and inserts it into the URI box. If this did not happened automatically, paste the URI into the URI box. All other fields complete automatically. The User is
git
and the Password is blank (since authentication is by SSH). Clone Git Repository dialog - Click through the remaining screens in the dialog. If this is the first time this user account on this computer has connected to GitHub via SSH, a couple of messages regarding keys may appear. Selecting the check boxes prevents the messages from appearing again.
The repository appears in the Git Repositories view. Repository in Git Repositories view
Share project
- In the Eclipse Package Explorer, right click on the project. Choose
Team -> Share Project
. Share Project option - In the Share Project dialog, select the repository cloned earlier. Ensure that the “Use or create repository in parent folder of project” box is NOT checked. Share Project dialog
The files from the project are listed in the Git Staging view under Unstaged Changes. It might be necessary to click on the repository in the Git Repositories view. Files in Unstaged Changes
Commit and push files
- In the Git Staging view, click the button with 2 green plus signs (tooltip: Add all files including not seleted ones to the index). Add all files The files move to Staged Changes.
- Enter a commit message (typically “initial commit”). Click the Commit and Push button. Commit and Push
The push result shows a new branch. New branch
The project files are visible on GitHub.com. (Refresh the page with the URI.) Project on GitHub
Eclipse project GitHub share video
The 2 links below are to the same video of an Eclipse project shared with GitHub. The YouTube version might show ads (YouTube’s, not mine). The Google Drive version should not show ads.