Learn Java Programming: Lesson 4 - How to Commit and Version your Code Using Github
Go Back to Course Outline I. What is Github? Github is a global company currently owned by Microsoft. Its core feature is an online ...

Go Back to Course Outline
I. What is Github?
II. Git Installation
- Download and install Git from https://git-scm.com/downloads.
- Check if it is properly installed by opening the command prompt and entering the command > git version.
III. Git Client Installation
- Install a Git client, I’m using Tortoise which is available for download at https://tortoisegit.org/download.
IV. Generate SSH Key
- Open your command prompt.
- Execute: ssh-keygen -t rsa -C "
" and answer the succeeding questions. Make sure to remember and write down your password. - Copy the generated files (id_rsa, id_rsa.pub) to your user's .ssh folder. For example in windows it's in c:\users\me\.ssh.
V. Create a Github Account
- Open your browser and navigate at https://github.com.
- Click the Signup button in the top-right corner.
- And enter your registration details with a valid email address.
- It should send a validation email to the email you use in registration and after clicking it, you should be able to log in and use Github.
- Login to Github and click the arrow down icon in the top-right corner. Then click Settings.
- On the right side, under the “Personal Settings” panel, click SSH and GPG keys.
- Copy the content of id_rsa.pub that we have created in the previous slide.
- In the SSH Keys screen, click New SSH Key.
- Fill in the Title and paste the id_rsa.pub content in the Key field.
- Your new key should be listed in the SSH Keys screen.
- Next, we will create our very first Github project.
VI. Creating our very first Github Project
- Login to your Github account.
- Create a new repository by either:
- Clicking the New button in the left panel with Repository title or;
- Clicking the plus icon in the top-right corner and select New Repository.
- Fill in the following details
- Repository name
- Description
- Public - means our project is accessible to anyone
- Don’t tick the Initialize this repository with a README.
- Click Create repository.
- In the repository detail copy the URL under the green “Clone or download” button. Should be in this format: git@github.com:czetsuya/hello-world2.git
VII. Pushing our hello-world2 Project
- Fire-up eclipse with the hello-world2 project that we have created in the previous video.
- Right-click on the hello-world2 project, select Team and then Share Project.
- You should arrive in the Share Project panel.
- Click “Use or create repository in parent folder of project".
- In the project list, select hello-world2.
- At the left-bottom part, click Create repository.
- Again right-click on the hello-world2 project, select Team then Commit.
- A new View “Git Staging” should open.
- Right-click the .gitignore file and click ignore if present.
- Drag the files from Unstaged Changes panel to Staged Changes.
- Add a commit message.
- Click “Commit”.
- Open, Git Repositories. In eclipse click Window / Show View / Other, in the filter enter git and select Git Repositories.
- In the Git Repositories view, you should be able to see the hello-world2 project.
- Right-click on the hello-world2 project, and select “Push Branch ‘master’”.
- A new panel “Destination Git Repository” should appear.
- In the Location / URI field paste the repository URL that we copied earlier when we created the repository in Github.
- Hit the Preview button and then Preview again. A Push Confirmation screen should show up with the details. In this case, we are pushing the master branch.
- Finally hit the Push-button.
- Congratulations! You just created your first Github project.
VIII. How does Github work?
- Modify the App.java. Add a new println line.
- Commit and push the changes to a remote repository.
- Check the github project online.
- Create and checkout a new branch integration.
- Modify App.java and commit.
- Merge the integration branch to master.
Post a Comment