What is GitHub?


GitHub is a web-based platform built on top of Git, a version control system. It allows developers to store, manage, and collaborate on code repositories online.

GitHub provides all the features of Git, but with additional tools and features like issue tracking, pull requests, team management, and automation workflows (GitHub Actions).

It is widely used for both open-source and private projects.


GitHub is primarily used for:

  • Collaborating on code: Multiple developers can work on the same project and share their code.
  • Version control: Track changes, revert to previous versions, and manage different versions of code (branches).
  • Hosting code: Stores the source code in remote repositories so it can be accessed from anywhere.
  • Project management: Features like Issues, Projects, and Discussions help manage tasks, bugs, and enhancements.


Key Features of GitHub

  1. Repositories (Repos): A project folder that contains code, files, and the entire history of changes.
  2. Version Control: GitHub uses Git’s version control system to track and manage changes in your codebase.
  3. Branches: Developers can create separate versions (branches) of the code for new features or bug fixes and merge them back into the main codebase.
  4. Pull Requests: Allows developers to review, discuss, and approve changes before merging them into the main codebase.
  5. Issues: A way to track bugs, tasks, or feature requests.
  6. Collaboration: Multiple contributors can work on the same project, and GitHub provides tools for collaboration.
  7. GitHub Actions: Automate workflows like testing code, deploying apps, or performing code checks.
  8. GitHub Pages: Host static websites directly from your GitHub repository.


How GitHub Works

Let's imagine you're working on a project with a team of developers to build a "Todo List App". Here’s how you would use GitHub to collaborate on the project.

1. Create a Repository

First, one developer creates a repository on GitHub. A repository is where the project’s code and its history will be stored. You can do this through the GitHub interface:

  • Go to GitHub → Click New Repository.
  • Name it todo-list-app.
  • Choose whether the repository will be public or private.

2. Clone the Repository

Each team member can clone the repository to their local machine to work on the project:

https://github.com/yeole-rohan/todo-list-app

This command copies the project to your computer, so you can start coding locally.

3. Create a Branch for a New Feature

If a developer wants to add a new feature, such as the ability to delete tasks from the todo list, they would create a branch to work on the feature without affecting the main codebase

git checkout -b delete-task-feature

This command creates a new branch named delete-task-feature and switches to it.

4. Make Changes and Commit

The developer writes the code for the delete task feature. Once the code is ready, they stage the changes and commit them.

git add .
git commit -m "Add delete task feature"

5. Push the Changes to GitHub

After committing, the changes are pushed to GitHub so others can see and review them.

git push origin delete-task-feature

This pushes the delete-task-feature branch to the GitHub repository.

6. Create a Pull Request

Once the developer is done with the feature, they create a pull request on GitHub, asking to merge the changes from the delete-task-feature branch into the main branch.

  • Go to the repository on GitHub → Click Pull Requests → Click New Pull Request.
  • Compare the delete-task-feature branch with the main branch, and then click Create Pull Request.
  • Other developers can now review the changes and provide feedback.

7. Code Review and Merge

Once the code has been reviewed and approved, the pull request is merged into the main branch. This adds the feature to the main project.

git merge delete-task-feature


GitHub Interface Overview

Here’s a breakdown of some of GitHub’s main sections:

  • Code: Where you can view the source code and the file structure of the repository. You can also see the history of commits.
  • Issues: A list of bugs, tasks, or feature requests related to the project. It’s used to track and manage work.
  • Pull Requests: A list of proposed changes to the codebase. Developers review pull requests before they are merged into the main project.
  • Actions: Automate workflows, like running tests when code is pushed or deploying code when merged.
  • Projects: Organize tasks and issues using Kanban-style boards.
  • Settings: Repository settings, where you can manage permissions, branches, and more.


Benefits of Using GitHub

  1. Collaboration: GitHub allows multiple developers to work on a project simultaneously, share code, and review changes.
  2. Version Control: GitHub tracks every change made to the code, allowing easy rollback and conflict resolution.
  3. Open Source: It’s a huge platform for open-source projects where developers can contribute to popular libraries and frameworks.
  4. CI/CD Integration: GitHub Actions helps automate testing, deployment, and other workflows, ensuring the project is stable.
  5. Documentation: GitHub allows projects to be documented via README.md files, making it easier for others to understand and contribute.


Summary

  • GitHub is a platform for hosting, sharing, and collaborating on code projects.
  • It provides version control using Git and offers tools for collaboration, project management, and automation.
  • Developers use GitHub to work together on projects, track issues, propose changes (pull requests), and manage the project lifecycle.

By using GitHub, teams can efficiently manage codebases, ensure code quality, and streamline their development process.