Playbook
Overview
This chapter is a quick-reference collection of recipes for common
Git tasks. Each recipe shows the problem, the commands to solve it,
and what to watch out for.
For command syntax, see the official Git reference.
For definitions, see Glossary.
Everyday
| Recipe | What you’ll find |
|---|
| Undoing Changes | Discard, unstage, reset, revert, and recover lost commits |
| Diffing | Unstaged, staged, between branches, commits, and files |
| History | Log formatting, filtering by author, date, and path |
| Stashing | Save and restore work in progress |
Branching and Merging
| Recipe | What you’ll find |
|---|
| Branching | Create, delete, rename, and inspect branches |
| Merging | Fast-forward, no-ff, squash, conflict resolution |
| Rebasing | Linearize history and squash commits interactively |
| Cherry-Picking | Apply individual commits across branches |
Remote
| Recipe | What you’ll find |
|---|
| Remote Operations | Push, pull, force push safely, sync forks |
| Remote Management | Add, rename, remove remotes, switch URL, SSH setup |
| SSH Setup | Key generation, agent, GitHub registration, troubleshooting |
| Bare Repositories | Create, clone, convert, and use bare repos as local remotes |
| Credentials | Credential helpers (cache, store, GCM), HTTPS tokens, security |
Project Structure
| Recipe | What you’ll find |
|---|
| Tagging | Create, push, and delete annotated tags |
| Submodules | Add, clone, update, and remove submodules |
| Remove a Submodule | Step-by-step cleanup — deinit, git rm, cached data |
| Subtrees | Add, pull, push, and remove subtrees |
| Git LFS | Track large files with pointer references and external storage |
Advanced
| Recipe | What you’ll find |
|---|
| Selectors | Tilde, caret, double-dot, triple-dot, reflog refs |
| Hooks | Pre-commit, commit-msg, sharing hooks, bypassing |
| Pre-commit Hook | Script creation, common checks, sharing and bypassing |
| Commit-msg Hook | Message validation, Conventional Commits, examples |
| Debugging | Bisect, blame, and search commit history |
| Git Bisect | Binary search for the commit that introduced a bug |
| Configuration | Identity, defaults, aliases, and diagnostics |