Skip to main content

Experiment No. 2 Title: Implement GitHub Operations using Git.

 Experiment No. 2

Title: Implement GitHub Operations using Git.


Objective:

The objective of this experiment is to guide you through the process of using Git commands to interact with GitHub, from cloning a repository to collaborating with others through pull requests.


Introduction:

GitHub is a web-based platform that offers version control and collaboration services for software development projects. It provides a way for developers to work together, manage code, track changes, and collaborate on projects efficiently. GitHub is built on top of the Git version control system, which allows for distributed and decentralised development.


Key Features of GitHub:

  • Version Control: GitHub uses Git, a distributed version control system, to track changes to source code over time. This allows developers to collaborate on projects while maintaining a history of changes and versions.

  • Repositories: A repository (or repo) is a collection of files, folders, and the entire history of a project. Repositories on GitHub serve as the central place where code and project-related assets are stored.

  • Collaboration: GitHub provides tools for team collaboration. Developers can work together on the same project, propose changes, review code, and discuss issues within the context of the project.

  • Pull Requests: Pull requests (PRs) are proposals for changes to a repository. They allow developers to submit their changes for review, discuss the changes, and collaboratively improve the code before merging it into the main codebase.

  • Issues and Projects: GitHub allows users to track and manage project-related issues, enhancements, and bugs. Projects and boards help organize tasks, track progress, and manage workflows.

  • Forks and Clones: Developers can create copies (forks) of repositories to work on their own versions of a project. Cloning a repository allows developers to create a local copy of the project on their machine.

  • Branching and Merging: GitHub supports branching, where developers can create separate lines of development for features or bug fixes. Changes made in branches can be merged back into the main codebase.

  • Actions and Workflows: GitHub Actions enable developers to automate workflows, such as building, testing, and deploying applications, based on triggers like code pushes or pull requests.

  • GitHub Pages: This feature allows users to publish web content directly from a GitHub repository, making it easy to create websites and documentation for projects.


Benefits of Using GitHub:


  • Collaboration: GitHub facilitates collaborative development by providing tools for code review, commenting, and discussion on changes.

  • Version Control: Git's version control features help track changes, revert to previous versions, and manage different branches of development.

  • Open Source: GitHub is widely used for hosting open-source projects, making it easier for developers to contribute and for users to find and use software.

  • Community Engagement: GitHub fosters a community around projects, enabling interaction between project maintainers and contributors.

  • Code Quality: The code review process on GitHub helps maintain code quality and encourages best practices.

  • Documentation: GitHub provides a platform to host project documentation and wikis, making it easier to document codebases and project processes.

  • Continuous Integration/Continuous Deployment (CI/CD): GitHub Actions allows for automating testing, building, and deploying applications, streamlining the development process.


Materials:

  • Computer with Git installed (https://git-scm.com/downloads)

  • GitHub account (https://github.com/)

  • Internet connection


Experiment Steps:


Step 1: Cloning a Repository

  • Sign in to your GitHub account.

  • Find a repository to clone (you can use a repository of your own or any public repository).

  • Click the "Code" button and copy the repository URL.

  • Open your terminal or command prompt.

  • Navigate to the directory where you want to clone the repository.

  • Run the following command:


git clone <repository_url>


  • Replace <repository_url> with the URL you copied from GitHub.

  • This will clone the repository to your local machine.


Step 2: Making Changes and Creating a Branch


Navigate into the cloned repository:


cd <repository_name>

  • Create a new text file named "example.txt" using a text editor.

  • Add some content to the "example.txt" file.

  • Save the file and return to the command line.

  • Check the status of the repository:

git status


  • Stage the changes for commit:

git add example.txt


  • Commit the changes with a descriptive message:

git commit -m "Add content to example.txt"


  • Create a new branch named "feature":

git branch feature


  • Switch to the "feature" branch:

git checkout feature



Step 3: Pushing Changes to GitHub

  • Add Repository URL in a variable 

git remote add origin  <repository_url>

  • Replace <repository_url> with the URL you copied from GitHub.


  • Push the "feature" branch to GitHub:

git push origin feature

  • Check your GitHub repository to confirm that the new branch "feature" is available.


Step 4: Collaborating through Pull Requests

  • Create a pull request on GitHub:

  • Go to the repository on GitHub.

  • Click on "Pull Requests" and then "New Pull Request."

  • Choose the base branch (usually "main" or "master") and the compare branch ("feature").

  • Review the changes and click "Create Pull Request."

  • Review and merge the pull request:

  • Add a title and description for the pull request.

  • Assign reviewers if needed.

  • Once the pull request is approved, merge it into the base branch.


Step 5: Syncing Changes

  • After the pull request is merged, update your local repository:

git checkout main

git pull origin main


Conclusion:

This experiment provided you with practical experience in performing GitHub operations using Git commands. You learned how to clone repositories, make changes, create branches, push changes to GitHub, collaborate through pull requests, and synchronise changes with remote repositories. These skills are essential for effective collaboration and version control in software development projects using Git and GitHub.


Questions:

  1. Explain the difference between Git and GitHub.

  2. What is a GitHub repository? How is it different from a Git repository?

  3. Describe the purpose of a README.md file in a GitHub repository.

  4. How do you create a new repository on GitHub? What information is required during the creation process?

  5. Define what a pull request (PR) is on GitHub. How does it facilitate collaboration among developers?

  6. Describe the typical workflow of creating a pull request and having it merged into the main branch.

  7. How can you address and resolve merge conflicts in a pull request?

  8. Explain the concept of forking a repository on GitHub. How does it differ from cloning a repository?

  9. What is the purpose of creating a local clone of a repository on your machine? How is it done using Git commands?

  10. Describe the role of GitHub Issues and Projects in managing a software development project. How can they be used to track tasks, bugs, and enhancements?


Comments

Popular posts from this blog

Experiment No. 5 Title: Applying CI/CD Principles to Web Development Using Jenkins, Git, and Local HTTP Server

  Experiment No. 5 Title: Applying CI/CD Principles to Web Development Using Jenkins, Git, and Local HTTP Server  Objective: The objective of this experiment is to set up a CI/CD pipeline for a web development project using Jenkins, Git, and webhooks, without the need for a Jenkinsfile. You will learn how to automatically build and deploy a web application to a local HTTP server whenever changes are pushed to the Git repository, using Jenkins' "Execute Shell" build step. Introduction: Continuous Integration and Continuous Deployment (CI/CD) is a critical practice in modern software development, allowing teams to automate the building, testing, and deployment of applications. This process ensures that software updates are consistently and reliably delivered to end-users, leading to improved development efficiency and product quality. In this context, this introduction sets the stage for an exploration of how to apply CI/CD principles specifically to web development using J

Experiment No. 10 Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform.

  Experiment No. 10 Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform. Objective: The objective of this experiment is to help you create a GitHub account and set up a basic CI/CD pipeline on GCP. You will learn how to connect your GitHub repository to GCP, configure CI/CD using Cloud Build, and automatically deploy web pages to an Apache web server when code is pushed to your repository. Introduction: Continuous Integration and Continuous Deployment (CI/CD) pipelines are essential for automating the deployment of web applications. In this experiment, we will guide you through creating a GitHub account and setting up a basic CI/CD pipeline using Google Cloud Platform (GCP) to copy web pages for an Apache HTTP web application. Continuous Integration and Continuous Deployment (CI/CD) is a crucial practice in modern software development. It involves automating the processes of code integration, testing, and deployment to ensure that software changes are co

Experiment No. 6 Title: Exploring Containerization and Application Deployment with Docker

  Experiment No. 6 Title: Exploring Containerization and Application Deployment with Docker  Objective: The objective of this experiment is to provide hands-on experience with Docker containerization and application deployment by deploying an Apache web server in a Docker container. By the end of this experiment, you will understand the basics of Docker, how to create Docker containers, and how to deploy a simple web server application. Introduction Containerization is a technology that has revolutionised the way applications are developed, deployed, and managed in the modern IT landscape. It provides a standardised and efficient way to package, distribute, and run software applications and their dependencies in isolated environments called containers. Containerization technology has gained immense popularity, with Docker being one of the most well-known containerization platforms. This introduction explores the fundamental concepts of containerization, its benefits, and how it differs