By Gayathri Vimalan
Click here for the previous part of the article where we covered step by step implementation of Cucumber project and how to generate reports.
In this Part 2, we are going to learn about how to integrate our project with GitHub Repository. Before integrating to GitHub, let’s understand Git first and how to create a public Git Repository.
Many of you confused between Git and GitHub. GitHub is just a website where we host our source code(Git repositories). It is a centralized system. Git doesn’t need GitHub but GitHub needs Git.
Git is a version control tool (software) that makes it easier to track changes in our source code. For example, whenever we are doing some changes, Git creates a commit. A commit is just a snapshot of current files when we edit a file, Git will help us determine exactly what was changed, who changed it.
Git mainly helps in tracking and merging different versions within the team. It also calculates and stores our main repository locally, making it faster.
Let’s start create an account in GitHub.
Go to https://github.com, please follow the steps there and create an account.
Now sign in to your GitHub account.
Step 1 : Create a Repository in GitHub
Click New as shown below.
Then go to Repository name and give name for our Repository and click Create repository as shown below.
Once the repository is created, we will be able to find the URL as shown in the snapshot below. It is the clone URL for our repository. Copy the link using the button provided at the end of the URL.
Step 2: Integrate project from Eclipse to GitHub
Open Eclipse and go to our project and right click, then click Team > Share Project.
Now we need to select the check box “Use or create repository in parent folder of project”, then click “Create Repository” button. Now our project will be selected automatically. As a final step, click Finish button.
Now go to project again in Eclipse and right click go to Team>Commit. Click Commit.
Now, the project files will be in “Unstaged Changes”. Click “Add all files” button (refer snapshot below) to move all the files from “Unstaged Changes” to “Staged Changes”.
Once the project files are moved to staged changes, then provide a commit message and then click “Commit and Push” button.
Now you will see a new dialog window. We can paste the URL that we got from the GitHub. And then enter Authentication details then click preview as shown below.
Those who are doing this step for the first time, will get an Authentication error. Please follow step 3 to solve it.
Step 3: How to get the Authentication details
Go to your GitHub and click on the settings as shown below.
And you will able to see Developer Settings on the bottom left pane. click it.
Click on the Personal access tokens>Tokens(classic)> Generate new token.
Give a name for your token and select all the check boxes and click Generate token as shown below
Now copy the token and paste it in password field in Eclipse and click Preview.
Now, “Push Branch master” dialog will appear. Click Preview and push as shown below.
Now we can see that project is pushing to GitHub (Refer snapshot below)
Now close the dialog window (refer snapshot below)
We pushed our project to GitHub.
I will show you how to integrate project with Jenkins in Part 3 of this series.
Enjoy Learning !!!!