How to run SpringBoot tests with GitHub Actions

Last Modified Date

HOME

GitHub Actions is a powerful tool that can be used to automate your software development workflows. In this blog post, we will show you how to get started with GitHub Actions for Java Spring Boot.

Why GitHub?

The flexible aspects of GitHub Actions enable users to create powerful, fast, and efficient automated testing workflows in CI/CD environments.

CI/CD pipelines have contributed to the success of the DevOps cycle in all software development projects. This is a holistic process that bridges development and operations. Continuous integration helps development teams deploy code efficiently, and continuous delivery automates code deployment.

Implementation Steps

Step 1 – Create GitHub Actions and Workflows

I have a repository available on GitHub – SpringBoot_Serenity_Cucumber_JUnit4_Demo as shown in the below image. Go to the “Actions” tab.  Click on the “Actions” tab.

Step 2 – Select the type of Actions

You will see that GitHub recommends Actions depending on the project. In our case, it is recommending actions suitable for a Java project. I have selected the “Java with Maven” option as my project is built in Maven.

Step 3 – Generation of Sample pipeline

If you choose an existing option, it will automatically generate a .yaml for the project as shown below.

We will replace the current workflow with the following yml file as shown below:

name: Build and Test Java Spring Boot Application 

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
   
    - name: Build with Maven
      run: mvn clean verify

    - name: Test Report
      uses: actions/upload-artifact@v3
      if: success() || failure()
      with:
          name: SpringBoot Report               # Name of the folder
          path: target/site/serenity/           # Path to test results

Step 4 – Commit the changes

After the changes, hit the “Commit changes” button.

This will give the option to add a description for the commit. It will enable the user to commit either to the main branch. The user can also commit to any other branch that exists in the project. Click on the “Commit changes” button to set up the workflow file.

Below is the image of the newly created maven.yml file.

Step 5 – Verify that the workflow is running

Next, head over to the “Actions” tab, and you will see your YAML workflow file present under the tab. The yellow sign represents that the job is in the queue.

In Progress – When the job starts building and running, you will see the status change from “Queued” to “in progress”.

Passed – If the build is successful, you will see a green tick mark. 

Failed – In case the build has failed, then there will be a red cross mark.

Click on the workflow and the below screen is displayed. It shows the status of the run of the workflow. It also shows the total time taken to run the workflow and the name of the .yml file.

Below shows all the steps of the workflow.

Step 6 – Published artifacts on GitHub

Once the pipeline run, a SpringBoot Report folder will be generated as shown in the below image:

When we click on the folder SpringBoot Report, a zipped file will be downloaded. We can extract it to see all the files contained within it.

The image of the report is shown below:

The complete code can be found here on GitHub – SpringBoot_Serenity_Cucumber_JUnit4_Demo.

Congratulations! We just created our CI workflow for running our SpringBoot test cases.

Integration of GitHub with Jenkins

Last Modified Date

HOME

The previous tutorial has explained how to install it onto a Windows 10 system and create a Maven or Gradle project in Jenkins. Jenkins and GitHub are two powerful tools on their own, but what about using them together? In this tutorial, learn about the benefits of a Jenkins GitHub integration and how to set up the integration on your own.

What is GitHub?

GitHub is a web-based version control system and collaboration platform for developers. It is the center around which all things involving git revolve. GitHub allows software developers and engineers to create remote, public-facing repositories on the cloud for free. Once you’ve set up a repository on GitHub, you can copy it to your device, add and modify files locally, then “push” your changes back to the repository where your changes display for the public.

What is Jenkins?

Jenkins is a well-known open-source tool that aids in the implementation of Continuous Integration (CI) and Continuous Deployment/Continuous Delivery (CD) processes by automating parts of the software development pipeline such as building, testing, and deployment.

Jenkins Version Used – 2.361.2

In this version of Jenkins, Git Plugin is already installed. If the Git Plugin is not installed, then follow the below steps to add Git Plugin in Jenkins.

Step 1: Open your dashboard

Click on the Manage Jenkins button on your Jenkins dashboard:

Step 2: Select Manage Plugins

Click on the Manage Jenkins. Choose Manage Plugins.

Step 3:  Add Git Plugin

On the Plugins Page, go to the Available option.

  1. Select the GIT Plugin
  2. Click on Install without restart. The plugin will take a few moments to finish downloading depending on your internet connection, and will be installed automatically.
  3. You can also select the option Download now and Install after the restart button. In which plugin is installed after the restart
  4. You will be shown a “No updates available” message if you already have the Git plugin installed.

In my case, Git Plugin is already installed, so you can’t see it in the Available Plugin.

Step 4: Verify Git Plugin is installed

Once the plugins have been installed,
Go to Manage Jenkins on your Jenkins dashboard. You will see your plugins listed among the rest.

How to Integrate Jenkins With GitHub

Step 1: Create a new project using the Maven project plugin

  1. Give the Name of the project.
  2. Click on the Maven project. 
  3. Click on the OK button.

In the General section, enter the project description in the Description box.

Click on create new jobs.

Enter the item name, select the job type, and click OK. We shall create a Maven project as an example.

Step 2: Describe the project in the description section

In the General section, enter the project description in the Description box.

Step 3 – Source Code Management section

You will see a Git option under Source Code Management if your Git plugin has been installed in Jenkins.

Enter the Git repository URL to pull the code from GitHub. Enter the credentials to log in to GitHub.

I have already set up the credentials to log in to GitHub. For first-time users, click on the Add button and select Jenkins.

Add the username and password used to log in to GitHub. Click on the “Add” button.

Note:- Please make sure that Git is installed on your local machine. To install Git on your local machine, go to this tutorial – How to install Git on Windows 10.

Step 4: Build Management

Go to the Build section of the new job.

  1. In the Root POM textbox, enter pom.xml
  2. In the Goals and Options section, enter “clean test

Step 5: Select “Publish TestNG Results” from “Post Build Actions”

Scroll down to “Post Build Actions” and click on the “Add Post Build Actions” drop-down list. Select “Publish TestNG Results“. In my case, the project is set up to generate TestNG Report, so I have selected TestNG. But if your project uses any other reporting option, please select that from the dropdown.

Enter TestNG XML Report Pattern as “**target/surefire-reports/testng-results.xml” and click on the “Apply” and “Save” button.

We have created a new project GitHub_Demo” with the configuration to run TestNG Tests and also to generate TestNG Reports after execution using Jenkins.

Step 6: Execute the tests

Let’s execute it now by clicking on the “Build Now” button. 

Right-click on Build Number (here in my case it is #1) and click on Console Output to see the result.

Below is the screenshot of the Console Output. It displays all the information regarding the execution of the tests.

Step 7: View the TestNG Report

Once the execution is completed, we could see a link to view “TestNG Results“.

Click on the TestNG Results. It displays the summary of the tests.

This way, we could integrate GitHub in Jenkins.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

How to run Gradle tests in the GitHub pipeline

HOME

The previous tutorial explained the steps to run the Selenium tests in the GitHub pipeline (Maven project). This tutorial explains the steps to run the Gradle project in the GitHub pipeline.

Important points to keep in mind:

1. We don’t need to think about the Chromedriver.exe we are using WebDriver Manager to handle that instead of adding it to our project like the following:

WebDriverManager.chromedriver().setup();

2. The Selenium tests need to run in the headless mode. As we are using Chrome browser, use the below code:

ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--headless");
driver = new ChromeDriver(options);

3. Install Chrome browser in ubuntu. Use the below code:

- uses: browser-actions/setup-chrome@latest
- run: chrome --version

To know more about Chrome installation, please refer to this tutorial – browser-actions/setup-chrome.

Implementation Steps

Step 1 – Create GitHub Actions and Workflows

I have a repository available on GitHub – Gradle_Selenium_TestNG_Demo as shown in the below image. Go to the Actions tab.  Click on the “Actions” tab.

Step 2 – Select the type of Actions

You will see that GitHub recommends Actions depending on the project. In our case, it is recommending actions suitable for a Java project. I have selected the “Publish Java Package with Gradle” option.

Step 3 – Generation of Sample pipeline

If you choose an existing option, it will automatically generate a .yaml for the project as shown below.

We will replace the current workflow with the following yml file as shown below:

name: Gradle Project - Selenium with TestNG

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        java-version: '11'
        distribution: 'temurin'
        
    - uses: browser-actions/setup-chrome@latest
    - run: chrome --version     

    - name: Build with Gradle
      run: gradle clean test
      
    - name: Archive Rest Results
      uses: actions/upload-artifact@v3
      if: success() || failure()
      with:
        name: test-results
        path: GradleReports/emailable-report.html

Step 4 – Commit the changes

After the changes, hit the “Start Commit” button.

This will give the option to add a description for the commit. It will also enable the user to commit either to the main branch or commit to any other branch that exists in the project. Click on the “Commit new file” button to set up the workflow file.

A folder with the name .github/workflows will be created that will contain a gradle-publish.yml file as shown below:

Step 5 – Verify that the workflow is running

Next, head over to the “Actions” tab, and you will see your YAML workflow file present under the tab. The yellow sign represents that the job is in the queue.

In Progress – When the job starts building and running, you will see the status change from “Queued” to “in progress”.

Passed –If the build is successful, you will see a green tick mark. 

Click on the workflow and the below screen is displayed. It shows the status of the run of the workflow, the total time taken to run the workflow, and the name of the .yml file.

Failed – In case the build has failed which in this case any of the tests is failed, then there will be a red cross mark.

Below shows all the steps of the workflow.

Build with Gradle steps failed because out of 2 tests, one of the tests failed. So, it appears in red colour. I personally love this feature because it gives an idea about the test execution status immediately if all the tests are passed or anything is failed.

Published artifacts on GitHub

Once the pipeline run, a test-results folder will be generated as shown in the below image:

When we click on the folder test-results, a zipped file will be downloaded, and we can extract it to see all the files contained within it.

The image of the report is shown below:

The complete code can be found here in GitHub.

How to upload artifacts in GitHub?

HOME

When a GitHub Actions workflow completes a build successfully, artifacts such as zip files, compiled code, Java JAR files, and other assembled components are created. Once the workflow is completed, the Docker container on which the GitHub Actions artifacts are created vanishes. However, it is not difficult for a developer to request that GitHub archive those artifacts and make them available as a downloadable link.

Steps to Publish GitHub Action Artifact

  1. Complete the GitHub Actions build steps. Add a stage for the Artifact – Test Report upload.

2. Enter the path to the files that must be uploaded. I’m copying all the files generated by Serenity that are in the target/site/serenity folder.

3. Use GitHub’s upload-artifact action to download all the files in the serenity folder and compress them into a zip file called Serenity Report.zip.

4. Run the GitHub Actions workflow and look for the published artifacts on the build page of the workflow.

How to create a GitHub Action?

Please refer to this tutorial to understand the steps to create a GitHub Action – How to run Selenium tests with GitHub Actions.

GitHub Action Artifact YAML Example

If the previous step is failed, and we still want to proceed to the next step, then use the below status syntax:

if: success() || failure()

To read more about the status check function, you can refer to this.

name: Serenity Rest Assured with JUnit4

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        java-version: '11'
        distribution: 'temurin'
        cache: maven
    
    - name: Build with Maven
      run: mvn clean verify
      
    - name: Test Report
      uses: actions/upload-artifact@v3
      if: success() || failure()
      with:
          name: Serenity Report               # Name of the folder
          path: target/site/serenity/           # Path to test results


Published artifacts on GitHub

From the logs of the Workflow, you can see that the Test Report step was executed successfully.

Once the pipeline run, a Serenity Report folder will be generated as shown in the below image:

When we click on the folder Serenity Report, a zipped file will be downloaded, and we can extract it to see all the files contained within it.

You can see the GitHub pipeline here – GitHub Artifact Upload.

How to run Selenium tests with GitHub Actions

Last Updated On

HOME

This tutorial explains the steps to create a GitHub Action for the Selenium tests and execute the tests in that workflow.

Table of Contents

  1. Why GitHub?
  2. Important points
  3. Implementation Steps
    1. Create GitHub Actions and Workflows
    2. Select the type of Actions
    3. Generation of Sample pipeline
    4. Commit the changes
    5. Verify that the workflow is running

Why GitHub?

The flexible aspects of Selenium WebDrivers and GitHub Actions enable users to create powerful, fast, and efficient automated testing workflows in CI/CD environments.

CI/CD pipelines have contributed to the success of the DevOps cycle in all software development projects. This is a holistic process that bridges development and operations. Continuous integration helps development teams deploy code efficiently, and continuous delivery automates code deployment.

Important points

1. We don’t need to think about the Chromedriver.exe we are using WebDriver Manager to handle that instead of adding it to our project like the example:

 WebDriverManager.chromedriver().setup();

2. The Selenium tests need to run in the headless mode. As we are using Chrome browser, use the below code:

          ChromeOptions options = new ChromeOptions();
          options.addArguments("--no-sandbox");
          options.addArguments("--disable-dev-shm-usage");
          options.addArguments("--headless");
	      driver = new ChromeDriver(options);

3. Install Chrome browser in ubuntu. Use the below code:

    - uses: browser-actions/setup-chrome@latest
    - run: chrome --version

Implementation Steps

Step 1 – Create GitHub Actions and Workflows

I have a repository available in GitHub – Selenium-TestNG as shown in the below image. Go to the “Actions” tab.  Click on the “Actions” tab.

Step 2 – Select the type of Actions

You will see that GitHub recommends Actions depending on the project. In our case, it is recommending actions suitable for a Java project. I have selected the “Java with Maven” option as my project is built in Maven.

Step 3 – Generation of Sample pipeline

If you choose an existing option, it will automatically generate a .yaml for the project as shown below.

We will replace the current workflow with the next yml file as shown below:

name: Selenium with TestNG - CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
    
    - uses: browser-actions/setup-chrome@latest
    - run: chrome --version
    
    - name: Build with Maven
      run: mvn -B clean test

The workflow file usually consists of the below attributes:

name: Java CI with Maven Name of workflow: This is an optional attribute.The name of the workflow is denoted by the keyword “name”. If you wish to include multiple CI jobs in your project, it is recommended to name each one appropriately.
on: [push] :
On attribute – This attribute is mandatory and specifies the trigger for this workflow. There are several actions you can include such as push, pull request, release, etc. for more information on the events, check the official guide here.
jobs: Under the jobs attribute, groups together all the jobs that run in the workflow.
runs-on: ubuntu-latest Configures the job to run on the latest version of an Ubuntu Linux runner. This means that the job will execute on a fresh virtual machine hosted by GitHub
steps: Under this option, the actions used by the particular workflow, and the multiple jobs that would run under the workflow are mentioned. These jobs run in parallel. If you want to run the jobs in the order in the CI pipelines, you must add the “needs” attribute. It is crucial to ensure that every workflow has at least one job. In our sample workflow, we only have one job as shown in image above.
uses: actions/checkout@v3
The uses keyword specifies that this step will run v3 of the actions/checkout action. This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools). You should use the checkout action any time your workflow will run against the repository’s code.
uses: actions/setup-java@v3
with:
java-version: ’17’
This step uses the actions/setup-java@v3 action to install the specified version of the Java (this example uses v17).

Step 4 – Commit the changes

After the changes, hit the “Start Commit” button.

This will give the choice to add a description for the commit. It will also allow the user to commit either to the main branch or commit to any other branch that exists in the project. Click on the “Commit new file” button to set up the workflow file.

Step 5 – Verify that the workflow is running

Next, head over to the “Actions” tab, and you will see your YAML workflow file available under the tab. The yellow sign represents that the job is in the queue.

In Progress – When the job starts building and running, you will see the status change from “Queued” to “in progress”.

Passed – If the build is successful, you will see a green tick mark. 

Click on the workflow and the below screen is displayed. It shows the status of the run of the workflow, the total time taken to run the workflow, and the name of the .yml file.

Below are all the steps of the workflow.

Failed – In case the build has failed, then there will be a red cross mark.

To learn more about Chrome installation, please refer to this tutorial – browser-actions/setup-chrome.

The complete code can be found here on GitHub – vibssingh/Selenium-TestNG.

Congratulations! We just created our CI workflow for running our Selenium test cases.

How to copy code from another version control to GitHub – GitHub Importer

HOME

What is GitHub Importer?

GitHub Importer is a tool that quickly imports source code repositories, including commits and revision history, from Subversion, Mercurial, Team Foundation Version Control (TFVC), or another Git repository to GitHub for you.

During an import, depending on the version control system you’re importing from, you can authenticate with your remote repository, update commit author attribution, and import repositories with large files (or remove large files if you don’t want to use Git Large File Storage).

Code Transfer from GitLab to GitHub

Implementation Steps

Step 1 – n the upper-right corner of any page, click +, and then click Import repository.

Step 2 – Under “Your old repository’s clone URL”, type the URL of the project you want to import. Here, I have mentioned the url of a project in GitLab.

Step 3 – Choose your personal account or an organization to own the repository, then type a name for the repository on GitHub.

Step 4 – Specify whether the new repository should be public or private. I have selected the public option.

Step 5 – Review the information you entered, then click Begin import.

Step 6 – If your old project requires credentials, type your login information for that project, then click Submit. If SAML SSO or 2FA are enabled for your user account on the old project, enter a personal access token with repository read permissions in the “Password” field instead of your password.

We can see that this project is now imported to GitHub.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

What is pull request in GitHub?

HOME

What is Pull Request?

Pull requests let others know about changes you’ve pushed to a branch of your repository on GitHub. When a pull request is opened, you can discuss and review potential changes with collaborators and add follow-up commits before the changes are merged into the base branch.

Prerequisite:

GIT is installed on the machine

Valid account on GitHub

Implementation Steps

If you want to create a new branch for your pull request and do not have write permissions to the repository, you can fork the repository first. 

1. Fork the repository

By clicking the fork button at the top of the page, you can fork the repository. This will make a copy of the entire repository in your account. To know more about Forking, please refer to this tutorial – How to Fork a GitHub repository.

2. Clone the repository

Once the repository has been added to your account, you can clone it to your machine to work with it locally.

Clone by clicking the clone button and copying the link as shown below.


Open the terminal (GitBash) and run the following command. It will clone the repository locally.

$ git clone https://github.com/vibssingh/GitHub-Demo.git

Now we have set up a copy of the master branch from the main online project repository.

We need to go to that cloned directory by running this command:

$ cd GitHub-Demo

3. Create a new branch

When working with repositories, whether it’s a small project or contributing to the work of a group, it’s the best practice to create a new branch.

The branch name should be short and reflect the work we are doing.

Now, use the below command to create a branch:

$ git checkout -B first_merge

4. Make changes and commit the changes

Make essential changes to the project and save it.

Then execute git status, and you’ll see the changes.

$ git status

Add those changes to the branch you just created using the below command:

$ git add .

Now commit those changes using the git commit command:

$ git commit -m "First Change by Vibha"

5. Push changes to GitHub

In order to push the changes to GitHub, we need to identify the remote’s name.

$ git remote

For this repository, the remote’s name is “origin”.

After identifying the remote’s name we can safely push those changes to GitHub.

$ git push origin first_merge

6. Create pull request

Go to your repository on GitHub, and you’ll see a button “Compare & pull request” click it.

Please provide the necessary details on what you’ve done (You can reference issues using “#”). Now submit the pull request.

7. Update the Local Repository

Before submitting any pull requests to the original repository, you must first sync your repository with it.

While working on a project with other contributors, keep your local repository up to date with the project because you don’t want to make a pull request for code that will automatically cause conflicts (though in collaborative code projects, conflicts are bound to occur). You’ll need to sync changes to keep your local copy of the code base up to date.

To update/sync those changes to your master branch, follow these steps:

1. First, check which branch you are in.

$ git remote

It’ll list all branches and indicates the current or active branch in green.

2. Switch to the master branch

git checkout main

3. Add the original repository as an upstream repository

In order to pull the changes from the original repository into your forked version, you need to add the original Git repository as an upstream repository.

git remote add upstream https://github.com/original-owner-username/original-repository.git

4. Fetch the repository

Fetch all the changes from the original repository. Commits to the original repository will be stored in a local branch called upstream/master.

$ git fetch upstream

5. Merge the changes

Merge the changes from the upstream/master into your local master branch. This will bring your fork’s master branch into sync with the upstream repository without losing your local changes.

$ git merge upstream/main

6. Push changes to GitHub

At this point, your local branch is synced to the original repository’s master branch. If you want to update the GitHub repository, you need to push your changes.

$ git push origin main

Congratulations! You’ve made your first pull request.

How to Clone a project from GitHub using Eclipse

Last Updated On

HOME

In this tutorial, we will clone a project from GitHub and import it in Eclipse.

Table Of Contents

  1. What is GitHub?
  2. Implementation Steps
    1. Clone the Project
    2. Import the project in Eclipse

What is GitHub?

GitHub is a for-profit organization that provides cloud-based Git repository hosting. It simplifies the use of Git for version control and collaboration by individuals and teams.
The GitHub interface is simple enough that even inexperienced coders can use it. Without GitHub, using Git generally necessitates a bit more technical know-how and command-line proficiency.

Furthermore, anyone can sign up for and host a public code repository for free, making GitHub particularly popular with open-source projects.

In this tutorial, I will explain how we can clone a project from GitLab in Eclipse.

Implementation Steps

Clone the Project

Step 1 – Go to GitHub and select the project which you want to clone. Click on the green colour “Code” button, then copy the hyperlink as shown in the image. You can either Clone with HTTPS, SSH, or GitHub CLI.

Import the project in Eclipse

Step 2 – Open Eclipse and go to File > Import in eclipse as shown in the image.

Step 3 – A window will pop up in which select Git Folder. Under the Git folder, select the option – Projects from Git (with smart import) as shown in the image.

Click on the NEXT button.

Step 4 – A new window will pop up in which select the option – Clone URI as shown in the image.

Click on the NEXT button.

Step 5 – Another window will pop up in which you have to paste the GitHub Repository URL and also GitHub User ID and Password and click on the “Next” button.

URI – This is the URL that we have cloned from GitHub in Step 1.
Host – github.com
Repository path – Path of the project in GitHub (This is auto-populated after entering URI)

Authentication
User – Username of GitHub
Password – Password of GitHub

Step 6 – Select main and selectWhen fetching a commit, also fetch its tags.

Click on the “Next” button.

Step 7 –  Select the Folder directory in which you want to import the repository.

Click on the Next button.

Step 8 – Select the Import Source, this is auto-generated. This wizard analyzes the content of the folder to find the project and import them into the IDE.

Click on the Finish button.

Step 9 – We have successfully imported the GitHub Repository as shown in the below image.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

How to Fork a GitHub Repository

HOME

A fork is a new repository that shares the original “upstream” repository’s code and visibility settings. Forks are frequently used in open-source projects or when a user does not have write access to the upstream repository to iterate on ideas or changes before they are proposed back to the upstream repository.

What is GitHub Repository Forking?

Assume you enjoy working on a specific framework or library. You discover a way to improve the functionality of this framework yourself one day.

The source code is available as a public repository on GitHub, so you can fork it to make a local copy.

Once you have a local copy of the code, you can make the necessary changes and request that the community review them.

Following a review of your code changes, the community may approve them or request additional changes. They are most likely to accept your code changes after they have been approved.

Prerequisites:

 Set up Git and authentication with GitHub.com from Git

How to Fork a Repo in GitHub

Step 1 – On GitHub.com, navigate to the octocat/Spoon-Knife repository.

Step 2 – In the top-right corner of the page, click Fork.

Step 3 – Select an owner for the forked repository. Here, the owner is vibssingh (as this is my username that is used to login).

Step 4 – By default, forks are named the same as their upstream repositories. You can change the name of the fork to distinguish it further.

Optionally, add a description of your fork.

Here, the new name is GitHub-Demo.

Step 5 – Choose whether to copy only the default branch or all branches to the new fork. For many forking scenarios, such as contributing to open-source projects, you only need to copy the default branch. By default, only the default branch is copied.

Step 6 – Click Create fork button.

This image shows that the GitHub repo is forked and present in your personal GitHub workspace.

We have successfully forked a repository in GitHub. I hope you have enjoyed this tutorial. Happy Learning!!

How to delete a repository on GitHub

HOME

The previous tutorial explained the steps to create a new repository in GitHub. In this tutorial, I will explain how we can delete n existing repository in GitHub.

It is important to note that you can delete any repository or fork if you’re either an organization owner or have admin permissions for the repository or fork. Deleting a forked repository does not delete the upstream repository.

  • Deleting a repository will permanently delete release attachments and team permissions. This action cannot be undone.
  • Deleting a private repository will delete all forks of the repository

Implementation Steps

Step 1 – Login to GitHub using your username and password.

Step 2 – Navigate to the main page of the repository. Under your repository name, click “Settings“.

Step 3 – Scroll down and, under “Danger Zone“, click the “Delete this repository” button.

Step 4 – To verify that you’re deleting the correct repository, type the name of the repository you want to delete.

Click the “I understand the consequences, delete this repository” button.

Step 5 – You need to re-login to confirm your access.

Congratulations!!. We have just deleted a repository in GitHub.