Skip to content

Git Recovering From Common Mistakes Textbook

A free, self-paced textbook in 8 chapters. Read a chapter, then drill it with the 105 companion flashcards using spaced repetition.

8 chapters · 105 cards · Updated

Chapters

  1. 1Undoing Commits and Local Changes

    Git offers a spectrum of "undo" commands whose power increases from safe to destructive. The lightest touch is git reset --soft HEAD~1, which moves the HEAD pointer back one commit...

  2. 2Cleaning the Working Tree and Fixing .gitignore

    Untracked files are handled separately from modifications, and git clean is the dedicated tool for removing them. By default it removes untracked files; adding -d extends it to unt...

  3. 3Rewriting History with Rebase

    Interactive rebase is Git's primary tool for cleaning up commits before sharing them. Running git rebase -i HEAD~5 opens an editor listing the last five commits; you can reorder li...

  4. 4Merging and Conflict Resolution

    Merging is Git's other way of combining work, and it offers several flags that change how branches are combined. The default git merge feature performs a fast-forward when possible...

  5. 5Stashing Work in Progress

    git stash provides a way to set work aside without committing it, useful when you need a clean working tree to switch branches, pull, or bisect. git stash push -m 'message' saves t...

  6. 6Branches, Remotes, Tags, and Force-Push Safety

    Branch housekeeping is mostly a matter of choosing the right safety flag. git branch -m new-name renames the current branch (use -M to force-overwrite an existing name). Deletion u...

  7. 7Investigating and Searching History

    Git's history tools answer different questions, and choosing the right one saves time. git log --oneline --graph --decorate --all renders the branch topology in the terminal so you...

  8. 8Advanced Recovery, Configuration, and Housekeeping

    For mistakes that have already entered shared history, rewriting tools are needed. To remove a committed secret, use git filter-repo or the BFG Repo-Cleaner to scrub it from every...

← Back to the Git Recovering From Common Mistakes deck