Hello everyone,
I have a new installation of eclipse (Version: 2021-09 (4.21.0)) on my local PC. And I wrote my first Java code on it. But working without backup and versioning is dangerous, so I want to synch my project with Github.com.
There are several ways to achieve this goal, here I show what I did:
Precondition: Prepare SSH Key
On Github click on: Your account/Settings/SSH and GPG Keys:
I already had a ssh key, if you are interested to see how I did it, ask me, I have it in my private doku (# Create ssh key:) or follow the public Github docu.
So I already had an "id_rsa" file (with the private key) in my .ssh folder.
And also the default entry was set in Eclipse/Window/Preferences/General/Network Connections/SSH2:
Creating a new Java Project in Eclipse:
We start from scratch and create a new Java project:
Now we create in this project a java package:
Now let's create the first Java Class:
After creation, we put in some content:
We also can copy and paste classes from other packages (in my case I copied Event.java into the hamurabi package).
Short check, if it is running by pressing F11 (Yes it is):
So, now I have a local java project. The next thing is to synchronize it with Github.
Create a local and Github Repository
Ricghtclick on the project name and click on "Team/Share Project":
Now, we have a local Git Repository:
Now I click on Window/Perspective/open Perspective/Git:
Then I rightclick on the repository and choose "Commit":
In the right lower windows, We have to choose all the new files and add them to the index. After that, we have to type in a comment for the commit. Then let's commit and push:
I get asked for the remote destination. As it does not exist until now, we have to create it on Github:
Then we can take the URI. In my case I use the SSH URI, because I already have the SSH Keys implemented and it is much more convienent instead of typing in the password every time I push or pull:
And put it into the URI-Field:
(This is an old Screenshot. Please exchange "Test" with "Hamurabi")
After clicking on Preview it looks like this:
Now let's push:
Yeah - It has worked. The files have been pushed to Github:
Regards, Achim Mertens