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.
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 daily workflow is simple:
git add . — Stage all your changesgit commit -m "your message" — Save with a descriptiongit push — Upload to GitHubgit pull — Download latest changesAlmost 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.
Branches let you work on features without affecting the main codebase. The standard flow:
feature/user-auth)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
PRs are how code gets reviewed before merging. They enable:
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
git stash — Temporarily save uncommitted changesgit log --oneline — Compact commit historygit diff — See what's changedgit blame file.js — See who wrote each linegit revert <commit> — Undo a specific commit safelyAfter years of daily Git usage, these are the advanced techniques, shortcuts, and recovery commands that separate power users from everyone else.
git rebase -i HEAD~5 # Edit last 5 commits
In the editor, you can:
squash — Combine commits into onereword — Change commit messagedrop — Delete a commit entirelyedit — Stop and amend a commitPro Tip
Clean up messy commit history before opening a PR. Squash "WIP" and "fix typo" commits into meaningful ones.
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.
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.
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
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
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
git config --global commit.gpgsign true # Verify commits are from you
git worktree add ../hotfix hotfix-branch # Work on two branches at once
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.
git reset --soft HEAD~1 — Undo commit, keep changes stagedgit reset --mixed HEAD~1 — Undo commit, keep changes unstagedgit reset --hard HEAD~1 — Undo commit, delete changes (careful!)git checkout -- . — Discard all unstaged changesgit clean -fd — Remove untracked files and directories. on any repo to open it in VS Code (web)t to fuzzy-find filesb to see blame view?w=1 to diff URLs to ignore whitespace.patch to any commit URL for downloadable patchgithub.dev instead of github.com for full VS Code editor