Skip to content

GitHub

Overview

GitHub is the world's largest software development platform, providing hosting for software development and version control using Git. It offers collaboration features, project management tools, and a vast ecosystem for developers.


Core Features

Repository Management

Feature Description Use Case
Git Integration Full Git version control Code versioning and collaboration
Branching Create and manage branches Feature development and bug fixes
Pull Requests Code review and merge requests Collaborative code review
Issues Bug tracking and feature requests Project management
Wiki Documentation hosting Project documentation
GitHub Pages Static website hosting Project websites and documentation

Collaboration Tools

Tool Purpose Benefits
Organizations Team management Access control and billing
Teams Subgroup management Granular permissions
Projects Kanban-style boards Workflow visualization
Discussions Community conversations Knowledge sharing
GitHub Sponsors Funding for open source Monetization support

Getting Started

Creating a Repository

# Create a new repository on GitHub
# 1. Go to https://github.com/new
# 2. Choose repository name
# 3. Add description
# 4. Choose public/private
# 5. Initialize with README (optional)
# 6. Add .gitignore and license (optional)

# Clone the repository locally
git clone https://github.com/username/repository-name.git
cd repository-name

# Or create locally first
mkdir my-project
cd my-project
git init
echo "# My Project" > README.md
git add README.md
git commit -m "Initial commit"
git remote add origin https://github.com/username/repository-name.git
git push -u origin main

Repository Structure

my-project/
├── .github/           # GitHub-specific files
│   ├── workflows/     # GitHub Actions
│   ├── ISSUE_TEMPLATE/
│   └── PULL_REQUEST_TEMPLATE/
├── docs/              # Documentation
├── src/               # Source code
├── tests/             # Test files
├── .gitignore         # Git ignore rules
├── LICENSE            # License file
├── README.md          # Project description
└── CONTRIBUTING.md    # Contribution guidelines

GitHub Actions (CI/CD)

Basic Workflow

# .github/workflows/ci.yml
name: CI

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.9'

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt

    - name: Run tests
      run: |
        python -m pytest

Advanced Workflow Features

# Multi-environment deployment
name: Deploy

on:
  push:
    branches: [ main ]

jobs:
  deploy-staging:
    runs-on: ubuntu-latest
    environment: staging
    steps:
    - uses: actions/checkout@v4
    - name: Deploy to staging
      run: echo "Deploying to staging"

  deploy-production:
    runs-on: ubuntu-latest
    environment: production
    needs: deploy-staging
    steps:
    - uses: actions/checkout@v4
    - name: Deploy to production
      run: echo "Deploying to production"

Common Actions

Action Purpose Example
actions/checkout Checkout repository uses: actions/checkout@v4
actions/setup-node Setup Node.js uses: actions/setup-node@v4
actions/setup-python Setup Python uses: actions/setup-python@v4
docker/build-push-action Build and push Docker images Multi-platform builds
aws-actions/configure-aws-credentials AWS authentication Deploy to AWS

Branching and Pull Requests

Branching Strategy

# Create feature branch
git checkout -b feature/new-feature

# Make changes and commit
git add .
git commit -m "Add new feature"

# Push branch to GitHub
git push origin feature/new-feature

# Create pull request on GitHub
# 1. Go to repository
# 2. Click "Compare & pull request"
# 3. Add description and reviewers
# 4. Create pull request

Pull Request Best Practices

Practice Benefit Implementation
Descriptive titles Clear understanding "feat: Add user authentication"
Detailed descriptions Context for reviewers What, why, how
Small PRs Easier review < 400 lines
Link issues Track progress "Closes #123"
Request reviews Quality assurance Assign reviewers
Update branch Latest changes Rebase before merge

Branch Protection Rules

# Repository Settings > Branches > Add rule
# Branch name pattern: main
# Require pull request reviews: ✓
# Require status checks: ✓
# Require branches to be up to date: ✓
# Include administrators: ✓

Issues and Project Management

Issue Templates

<!-- .github/ISSUE_TEMPLATE/bug_report.md -->
---
name: Bug Report
about: Create a report to help us improve
title: "[BUG] "
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment:**
 - OS: [e.g. Windows 10]
 - Browser [e.g. chrome, safari]
 - Version [e.g. 22]

**Additional context**
Add any other context about the problem here.

Project Boards

# Project board columns
To Do     | In Progress | Review     | Done
----------|-------------|------------|------
Issue #1  | Issue #2    | PR #3      | Issue #4
Issue #5  |             |            |

Labels

Label Color Purpose
bug #d73a49 Something isn't working
enhancement #a2eeef New feature or request
documentation #0075ca Documentation needed
good first issue #7057ff Good for newcomers
help wanted #008672 Extra attention needed
question #d876e3 Further information needed

GitHub CLI

Installation

# Install GitHub CLI
# macOS
brew install gh

# Windows
winget install --id GitHub.cli

# Linux
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

Authentication

# Authenticate with GitHub
gh auth login

# Or use token
gh auth login --with-token < token.txt

Common Commands

# Repository operations
gh repo create my-project
gh repo clone owner/repo
gh repo fork owner/repo

# Issue management
gh issue list
gh issue create --title "Bug report" --body "Description"
gh issue view 123

# Pull request operations
gh pr create --title "Feature" --body "Description"
gh pr list
gh pr checkout 123
gh pr merge 123

# Repository status
gh repo view
gh repo stats

GitHub Pages

Static Site Hosting

# .github/workflows/deploy.yml
name: Deploy to GitHub Pages

on:
  push:
    branches: [ main ]

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Pages
        uses: actions/configure-pages@v4

      - name: Build with Jekyll
        uses: actions/jekyll-build-pages@v1
        with:
          source: ./
          destination: ./_site

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3

  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

Custom Domain

# Create CNAME file in docs/ or root
echo "www.example.com" > CNAME

# Or for apex domain
echo "example.com" > CNAME

Security Features

Dependabot

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    open-pull-requests-limit: 10

  - package-ecosystem: "docker"
    directory: "/docker"
    schedule:
      interval: "weekly"

  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"

Code Scanning

# .github/workflows/codeql.yml
name: "CodeQL"

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  schedule:
    - cron: '0 6 * * 1'  # Weekly on Mondays

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Initialize CodeQL
      uses: github/codeql-action/init@v3
      with:
        languages: javascript

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v3

Secret Scanning

# Repository Settings > Security > Secret scanning
# Enable secret scanning: ✓
# Push protection: ✓ (blocks commits with secrets)

GitHub Packages

Publishing Packages

# .github/workflows/publish.yml
name: Publish Package

on:
  release:
    types: [published]

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 18
          registry-url: https://npm.pkg.github.com/
      - run: npm ci
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Using Private Packages

// package.json
{
  "name": "@octo-org/octo-app",
  "version": "1.0.0",
  "dependencies": {
    "@octo-org/private-package": "^1.0.0"
  }
}

Best Practices

Practice Benefit Implementation
Use meaningful commit messages Clear history "feat: Add user authentication"
Keep PRs small Easier review < 400 lines per PR
Use issue templates Consistent reporting Standardized bug/feature reports
Enable branch protection Code quality Require reviews and tests
Use GitHub Actions Automation CI/CD pipelines
Regular security scans Vulnerability detection Dependabot and CodeQL
Clear documentation Onboarding README, CONTRIBUTING, CODE_OF_CONDUCT
Semantic versioning Predictable releases v1.0.0, v1.1.0, v2.0.0

Advanced Features

GitHub Copilot

GitHub Copilot is an AI-powered code completion tool that suggests code and entire functions based on context.

# Example: Copilot can suggest this function
def calculate_fibonacci(n):
    if n <= 1:
        return n
    return calculate_fibonacci(n-1) + calculate_fibonacci(n-2)

# Usage
print(calculate_fibonacci(10))  # 55

GitHub Sponsors

# .github/FUNDING.yml
github: [username]
patreon: username
open_collective: project-name
ko_fi: username
tidelift: pypi/package-name
community_bridge: project-name
liberapay: username
issuehunt: username
otechie: username
custom: ['https://www.paypal.me/username']

GitHub Enterprise

GitHub Enterprise provides additional features for organizations:

  • Advanced Security: Secret scanning, dependency review
  • Compliance: Audit logs, data retention policies
  • SAML SSO: Single sign-on integration
  • Advanced Auditing: Detailed activity logs
  • 24/7 Support: Enterprise-grade support

Common Commands Reference

Command Description
gh repo create Create a new repository
gh repo clone Clone a repository
gh issue list List repository issues
gh pr create Create a pull request
gh pr merge Merge a pull request
gh workflow run Run a GitHub Actions workflow
gh release create Create a release
gh auth login Authenticate with GitHub

Resources