Lesson 29 of 60 – Introduction to GitHub
48%

Introduction to GitHub

GitHub is a web-based platform for hosting Git repositories and collaborating on software projects. It provides features that help developers store code, work with other developers, review changes, manage issues, and automate development workflows.

Note: Git and GitHub are different. Git is a distributed version control system, while GitHub is a platform that provides hosting and collaboration features around Git repositories.

1. What is GitHub?

GitHub is a platform where developers can host Git repositories and collaborate on software projects.

A GitHub repository can contain source code, documentation, configuration files, and other project files.

2. Git vs GitHub

Git GitHub
Version control system Development and collaboration platform
Runs locally Provides online repository hosting
Tracks project history Provides collaboration tools
Uses commands such as commit and branch Provides features such as pull requests and issues

3. GitHub Repositories

A GitHub repository is a project space that stores files and Git history.

For example:

my-website
├── index.html
├── style.css
├── script.js
└── README.md

4. Why Use GitHub?

GitHub provides many features for software development and collaboration.

  • Host Git repositories
  • Share projects
  • Collaborate with developers
  • Review code changes
  • Track issues
  • Manage project work
  • Automate workflows
  • Publish documentation and websites

5. GitHub and Remote Repositories

A GitHub repository can be used as a remote repository for a local Git project.

Local Repository
       ↕
   Git Remote
       ↕
GitHub Repository

Commands such as git push and git pull can be used to synchronize changes.

6. GitHub Account

A GitHub account provides access to GitHub's platform features. After signing in, users can create repositories, manage projects, participate in collaboration, and configure their profiles.

7. GitHub Profile

A GitHub profile represents a user's activity and public presence on the platform.

Depending on the user's settings and activity, a profile can contain repositories, contributions, profile information, and other public activity.

8. Public and Private Repositories

GitHub repositories can have different visibility settings.

  • Public: The repository can be visible to people on GitHub according to its access settings.
  • Private: Access is restricted to authorized users and collaborators.

Repository visibility should be selected according to the project's requirements.

9. Creating a GitHub Repository

A repository can be created on GitHub for a new or existing project.

A repository normally has a name and can include optional project information such as a description and README file.

10. Connecting a Local Repository to GitHub

After creating a repository on GitHub, you can connect a local Git repository to it.

git remote add origin https://github.com/user/project.git

The remote can then be verified with:

git remote -v

11. Pushing Code to GitHub

After committing changes locally, you can push them to GitHub.

git push -u origin main

This sends the local main branch to the origin remote.

12. Pulling Code from GitHub

You can retrieve and integrate changes from a GitHub repository using git pull.

git pull origin main

This is useful when changes have been made to the remote repository.

13. Cloning a GitHub Repository

The git clone command creates a local copy of a GitHub repository.

git clone https://github.com/user/project.git

The cloned repository includes its Git history and remote configuration.

14. GitHub Issues

GitHub Issues can be used to track tasks, bugs, feature requests, questions, and other project work.

For example:

Issue #25
Fix login validation

15. Pull Requests

A pull request is a way to propose changes from one branch or repository to another and discuss those changes before integration.

Pull requests are commonly used for code review and collaboration.

16. Code Review

GitHub provides tools for reviewing proposed code changes. Team members can inspect changed files, leave comments, and discuss modifications through pull requests.

17. GitHub Branches

Branches allow developers to work on different lines of development.

main
feature-login
bugfix-payment

Developers can create branches locally and push them to GitHub.

18. GitHub Forks

A fork is a copy of a repository under another user's or organization's account.

Forks are commonly used when someone wants to work on a project without directly modifying the original repository.

19. GitHub Collaborators

Repository owners can provide other users with access to collaborate on a repository according to the repository's configured permissions.

Collaborators can work together on issues, branches, pull requests, and repository files according to their access level.

20. GitHub README

A README.md file provides information about a project. It is commonly written using Markdown.

A README may contain:

  • Project description
  • Installation instructions
  • Usage instructions
  • Features
  • Examples
  • Contribution information

21. GitHub Releases

GitHub provides release features that can organize published versions of a project around Git tags.

For example, a project may have a release associated with:

v1.0.0

22. GitHub Actions

GitHub Actions provides automation capabilities for repositories. Workflows can be used to automate tasks such as testing, building, and deployment.

Code Push
    ↓
Workflow
    ↓
Test
    ↓
Build
    ↓
Deploy

23. GitHub Projects

GitHub Projects provides tools for organizing and tracking project work.

Teams can use project views and work items to organize tasks and monitor progress.

24. GitHub Discussions

GitHub Discussions provides a space for conversations around a repository or community.

It can be used for questions, announcements, ideas, and general project discussions where enabled.

25. GitHub Pages

GitHub Pages can be used to publish websites from GitHub repositories.

It is commonly used for documentation, project pages, portfolios, and static websites.

26. GitHub Security

GitHub provides security-related features that can help developers identify and manage security issues in repositories.

Developers should also avoid committing passwords, API keys, private keys, or other sensitive credentials to repositories.

27. GitHub Repository Workflow

Create Repository
        ↓
Clone / Connect Repository
        ↓
Create Branch
        ↓
Make Changes
        ↓
Commit Changes
        ↓
Push Branch
        ↓
Create Pull Request
        ↓
Review Changes
        ↓
Merge

This is a common collaboration workflow on GitHub.

28. Basic GitHub Commands

git clone URL
git remote -v
git status
git add .
git commit -m "Message"
git push origin main
git pull origin main
git fetch origin

These are Git commands commonly used when working with GitHub repositories.

29. Simple GitHub Project Example

git clone https://github.com/user/my-project.git

cd my-project

git switch -c feature-login

# Make changes

git add .
git commit -m "Add login page"

git push -u origin feature-login

After pushing the branch, a pull request can be created on GitHub for review and integration.

30. Summary of GitHub

GitHub is a platform for hosting Git repositories and collaborating on software projects.

GitHub works with Git and provides additional tools such as repositories, branches, pull requests, issues, code review, collaborators, projects, releases, Actions, and Pages.

Git → Version Control
GitHub → Hosting + Collaboration Platform

📌 Key Points

  • GitHub is a platform for hosting Git repositories.
  • Git and GitHub are different technologies.
  • A GitHub repository stores project files and Git history.
  • Repositories can have different visibility settings.
  • git clone downloads a repository to your computer.
  • git push sends local commits to a remote repository.
  • git pull retrieves and integrates remote changes.
  • GitHub Issues can track bugs and project tasks.
  • Pull requests are used to propose and review changes.
  • Forks provide copies of repositories under another account.
  • README files document projects.
  • GitHub Actions can automate development workflows.
  • GitHub Pages can publish static websites.

🧠 Quick Quiz

Question: What is GitHub primarily used for?