Clean up Git history safely: rebase, squash, reflog

11 steps · about 3 h 20 min · Intermediate

  1. Merging vs. Rebasing (guide, Atlassian Git Tutorial, 20 min)

    Start with what rebase does and the golden rule (never rebase public branches), so you know when rewriting history is safe.

  2. Learn Git Branching (interactive, Peter Cottle, 40 min)

    A visual sandbox lets you watch commits move during rebase, cherry-pick and interactive rebase with no risk to a real repo.

  3. 7.6 Git Tools - Rewriting History (doc, Pro Git (git-scm.com), 30 min)

    The official book chapter explains amend, reword, reorder and squash, and why rewriting one commit rewrites all the ones after it.

  4. Git rebase (guide, Atlassian Git Tutorial, 15 min)

    It covers the interactive todo-list commands and the usual workflow of polishing a feature branch before merging.

  5. Git interactive rebase: edit, squash and undo commits (article, Darragh ORiordan, 15 min)

    A hands-on walkthrough of reword, edit, squash, fixup and drop, with a tip to create a restore marker before you start.

  6. How to Squash Commits in Git (Step-by-Step with Examples) (tutorial, Codecademy, 10 min)

    It compares squashing with interactive rebase against git merge --squash, so you can choose the right tool.

  7. Smoother rebases with auto-squashing Git commits (blog, Andrew Lock, 10 min)

    Once squashing is routine, fixup commits and --autosquash make the cleanup much faster.

  8. 10.7 Git Internals - Maintenance and Data Recovery (doc, Pro Git (git-scm.com), 20 min)

    This shows why your safety net exists: Git silently records every HEAD move, so lost commits can usually be found.

  9. Understanding Git's reflog feature (article, Initial Commit, 15 min)

    It gives practical reflog examples, including recovering a deleted branch and undoing a rebase.

  10. How to Handle Git Interactive Rebase (article, OneUptime, 15 min)

    It pulls everything together with abort and continue, reflog and reset to recover, and push --force-with-lease for safely publishing rewritten work.

  11. Git - git-reflog Documentation (reference, git-scm.com, 10 min)

    Finish with the official reference for reflog syntax, like HEAD@{n}, and how entries expire.