← Back to Wiki

Development Tools

GitHub is a website where developers store and share their code. Think of it like Google Drive, but specifically designed for code projects.

What Problem Does It Solve?

Imagine you're writing a paper and want to save different versions. You might save files like "essay_v1.doc", "essay_v2.doc", "essay_final.doc". GitHub does this automatically for code, letting you track every change and go back to any previous version.

The Basics

The Essential Workflow

The daily workflow is simple:

  1. Make changes to your code
  2. Save those changes with a commit message
  3. Push to GitHub so it's backed up in the cloud

Key Commands

Why It Matters

Almost every software company uses GitHub or something similar. Learning it is essential for any developer, and it's free to use for personal projects.

Beyond basic version control, GitHub is a full collaboration platform. Understanding branches, pull requests, and GitHub's ecosystem unlocks team workflows and open-source contribution.

Branching Strategy

Branches let you work on features without affecting the main codebase. The standard flow:

git checkout -b feature/new-dashboard    # Create and switch to new branch
git push -u origin feature/new-dashboard  # Push branch to GitHub
git checkout main                          # Switch back to main
git merge feature/new-dashboard            # Merge feature into main

Pull Requests (PRs)

PRs are how code gets reviewed before merging. They enable:

GitHub Actions (CI/CD)

Automate testing, building, and deployment with workflow files:

# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: npm install
      - run: npm test

Useful Commands

GitHub Features

After years of daily Git usage, these are the advanced techniques, shortcuts, and recovery commands that separate power users from everyone else.

Advanced Git Commands

Interactive Rebase (Rewrite History)

git rebase -i HEAD~5  # Edit last 5 commits

In the editor, you can:

Pro Tip

Clean up messy commit history before opening a PR. Squash "WIP" and "fix typo" commits into meaningful ones.

Cherry Pick

git cherry-pick abc123  # Apply a specific commit to current branch

Perfect for pulling a bug fix from one branch to another without merging everything.

Reflog (Git's Safety Net)

git reflog                    # See all HEAD movements
git reset --hard HEAD@{3}     # Go back to a previous state

Even after a bad reset or deleted branch, reflog can save you. Git remembers everything for ~90 days.

Bisect (Find Buggy Commits)

git bisect start
git bisect bad                 # Current commit is broken
git bisect good v1.0.0         # This version worked
# Git will binary search to find the breaking commit

GitHub CLI (gh)

The official CLI is incredibly powerful:

gh pr create --fill            # Create PR from current branch
gh pr checkout 123             # Check out PR #123 locally
gh pr merge --squash           # Squash merge current PR
gh issue list --assignee @me   # Your assigned issues
gh repo clone owner/repo       # Clone with one command
gh run watch                   # Watch CI/CD in terminal

Aliases (Speed Up Everything)

Add to ~/.gitconfig:

[alias]
    co = checkout
    br = branch
    ci = commit
    st = status
    lg = log --oneline --graph --all
    undo = reset HEAD~1 --mixed
    amend = commit --amend --no-edit
    wip = !git add -A && git commit -m 'WIP'
    pushf = push --force-with-lease  # Safer force push

Advanced Workflows

Signed Commits

git config --global commit.gpgsign true  # Verify commits are from you

Worktrees (Multiple Branches Simultaneously)

git worktree add ../hotfix hotfix-branch  # Work on two branches at once

Partial Staging

git add -p  # Stage specific chunks, not whole files

Power Move

Use git add -p to split a day's work into logical, atomic commits. Your code reviewers will thank you.

Recovery Commands

GitHub Keyboard Shortcuts