Git and GitHub Guide: Commits, Branches, Pull Requests

Git feels confusing until you see what it stores: snapshots and pointers. This guide starts with that mental model, then builds up the daily commands, branching, pull requests and the safe ways to undo mistakes.

Every command was run in a throwaway repository, and the real output is shown.

Who it is for: Developers who use Git every day but still feel unsure about merges, rebases or recovering lost work.

9 lessons · Published by Jainik · Last updated

1. The mental model and the daily loop

  1. 1. Git & GitHub · 7 min
    The Mental Model: Snapshots, Commits and Branches

    The working tree, the staging area and the repository, how a commit is a snapshot with a parent, and how branches and HEAD are just pointers.

  2. 2. Git & GitHub · 9 min
    The Daily Loop: Status, Add, Commit, Diff and Log

    The commands you use every day, .gitignore, good commit messages and staging parts of a file with git add -p.

2. Branches, remotes and pull requests

  1. 3. Git & GitHub · 8 min
    Branches, Merging and Conflicts

    Fast-forward versus merge commits, and a real merge conflict resolved step by step.

  2. 4. Git & GitHub · 9 min
    Remotes, Pull Requests and Code Review

    Remotes, fetch versus pull, upstream tracking, forks, and the pull request flow with review habits.

  3. 5. Team Lead Mindset · 15 min
    Estimates, Code Review and Priorities

    Honest ranges with named unknowns, missed deadlines, quick fix versus proper fix, reviewing for better-not-perfect, and saying no with an option.

3. Undoing things and clean history

  1. 6. Git & GitHub · 10 min
    Undoing Things Safely: Restore, Reset, Revert, Reflog and Friends

    The undo tools run for real, recovering a lost commit with reflog, bisect, and a table of which command to use.

  2. 7. Git & GitHub · 11 min
    Rebase, Clean History and Team Workflows

    Rebase versus merge, tidying history, force-with-lease, branch protection, CODEOWNERS and a first GitHub Actions workflow.

4. Team workflow and automation

  1. 8. Full-Stack Questions · 30 min
    Git, Team Workflow and Monorepos

    Merge vs rebase, undoing mistakes, reflog, bisect, branching models, code review, pnpm workspaces, Turborepo, changesets and versioning.

  2. 9. DevOps · 22 min
    CI/CD with GitHub Actions

    Lint, test, build and deploy on every push — automatically, with no one SSH-ing into a server.

More reading orders are on the guides page, and every series is listed on the home page.