“Boost Your Git DX” out now

The book art: a custom drawing of the Git logo, tiled.

My new book, Boost Your Git DX is out now, on my birthday 🥳. It’s taken nearly a year of work with four months in early access.

This book is 353 pages across 18 chapters on improving your Git command line development experience. It covers the best tools, techniques, tips, tricks, and tactical tidbits that I’ve encountered in 11 years of using Git.

Buy it now on Gumroad

Team licenses are available and there’s an automatic regional discount for those in lower-income countries. It comes in DRM-free PDF, ePub, and AZW3.

Praise

Response from beta and early access readers has been encouraging. There’s a list of public posts about the book at the bottom of the Gumroad page. Here’s a selection:

whether you're new to git or an experienced veteran -- @AdamChainz's new book "Boost Your Git DX" has something for everyone! (even I learned a cool new thing: git config --show-origin)

Anthony Sottile on Twitter

Adam's written two books before (Boost Your Django DX; Speed Up Your Django Tests) — both paid for themselves within the first hour of my purchase.

This one's a no-brainer, too.

Justin Duke on Twitter

This book transformed my day-to-day operations. As a self-taught engineer, I have found myself starved for mentorship, and Boost Your Git DX has been my most influential mentor in 2023.

Lance Goyke on his blog

Free samples

Some of the book’s content is adapted from previous posts, including:

Full table of contents

Update (2024-04-04): See the update blog post for the latest table of contents.

Here’s what you’ll learn within:

  1. Introduction
    1. About this book
      • Read in any order
      • Example commands and resources
      • End-of-chapter feedback links
    2. Acknowledgements
    3. Changelog
  2. Global configuration
    1. Git’s configuration files
      • Store global configuration in ~/.config/git
      • Migrate from legacy ~/.gitconfig to ~/.config/git/config
      • Read and change options with git config
      • Trace options with git config --show-scope and --show-origin
    2. Basic configuration
      • Set your name and email address
      • Use a different email address based on the working directory
      • Use your favourite editor
      • Set up a global ignore file
      • Improve the default colourization with color.* options
      • Enable help.autoCorrect to fix mistyped commands
    3. Back up your configuration
      • Set up your dotfiles repository
      • Save ongoing configuration changes
      • Track other configuration files
      • Restore your backup
  3. Aliases
    1. Shell aliases
      • Create shell aliases with alias <name>=<command>
      • List aliases with alias
      • Bypass aliases with \
    2. Git aliases
      • Create an alias that runs a single Git command
      • Create an alias that runs shell commands
      • Add a git git alias to help when you lose attention
  4. Shell configuration
    1. oh-my-zsh: instant enhancements and aliases
      • Install oh-my-zsh
      • Some handy Git aliases
      • Learn your aliases on the go with zsh-you-should-use
    2. Starship: a powerful, performant prompt
      • Install Starship
      • Personalize your prompt
      • Read Git state at a glance with Starship’s prompt
  5. Shell tools
    1. Less: the power pager
      • Activate lesser-known features with the LESS environment variable
      • Scroll and search with keyboard shortcuts
      • Search forwards with / and backwards with ?
      • Use Less with more Git commands
    2. delta: dapper diff display
      • Set up Git to use delta
      • How delta enhances Git’s output
      • Run delta directly as a diff tool
    3. ripgrep: rip-roaringly rapid grep
      • Install ripgrep
      • Search basics
      • Change case sensitivity with -i or -S
      • Unrestrict searches with specific options or -u
      • Filter by file extensions with -g or -t
      • Configure ripgrep in ~/.config/ripgreprc
      • Combine with delta for lovely formatting
  6. Repository configuration
    1. Default branch naming
      • Use main for your default branches
      • Alias master as main in legacy repositories
    2. Ignore files
      • The basics of ignore files
      • Ignore file tips
      • Commands for debugging ignore files
  7. Hooks and the pre-commit framework
    1. Git hooks
    2. pre-commit: Universal Hook Manager
      • Install pre-commit
      • Configure pre-commit
      • Update hooks with pre-commit autoupdate
      • Extra protection from pre-commit-hooks
      • ripsecrets: Protect your secrets
      • Find more hooks
      • Skip hooks temporarily with --no-verify or SKIP
      • oh-my-zsh plugin
      • pre-commit ci: continuous integration for your hooks
  8. Command commonalities
    1. Common options
      • Get short or long help with -h or --help
      • Override configuration with -c
      • Use repositories in other directories with -C
    2. Commit SHAs
      • SHA abbreviation
      • Show and copy the current commit SHA
      • SHA-1 versus SHA-256
    3. Commit references
      • Single commit references
      • Commit range references
    4. Date specifications
      • Top formats
    5. Pathspecs
      • Top pathspec syntaxes
      • Using pathspecs
  9. Branches and worktree
    1. Switching branches
      • Use git switch instead of git checkout
      • Top git switch commands
    2. Listing branches
      • Basic branch listing commands
      • Sort by recency and switch with fzf (fuzzy finder)
      • Find branches missing a given commit
    3. Deleting old branches
      • Configure your Git host to delete merged branches
      • Enable automatic pruning of remote branches
      • Add an alias to delete local branches
    4. worktree
      • worktree basics
      • Using a worktree to write a hotfix
  10. status and diff
    1. status
      • Use short format for denser output
      • Shorten long format by disabling advice with advice.statusHints
      • Hide untracked files with -uno
      • List changed files with git diff --name-only
    2. diff
      • Improve diff generation with the “histogram” algorithm
      • Enable inter-hunk context for more… context
      • Enable language-specific hunk headings
      • Use ExifTool to diff media files
      • Use Pandoc to diff document files
      • Disable file path prefixes to make them copyable
  11. add and restore
    1. add (and mv and rm)
      • The three commands: add, mv, and rm
      • Add interactively with git add -p
      • Add all changes with git add -u or -A
    2. restore
      • Use git restore instead of checkout and reset
      • Top git restore commands
      • Restore interactively with -p
  12. commit and reset
    1. commit
      • Improve commit message editing with verbose mode and “scissors” cleanup
      • Use -m to set the message without your editor
      • Use -a or an alias to add all files and commit
      • Declare coauthors in co-authored-by trailers
      • Update the previous commit with --amend
      • Create empty commits with --allow-empty
    2. reset
      • Undo commits and keep their changes with --mixed or --soft
      • Undo commits and discard their changes with --keep (not --hard)
      • Useful commit references for resetting
  13. stash and apply
    1. stash
      • stash basics
      • Push stash entries with a description with -m
      • Stash selected files by pathspec
      • Stash only unstaged changes with -k or staged changes with -S
      • Stash selected hunks interactively with -p
      • Automatically stash during merge and rebase with the autostash options
    2. apply
      • apply basics
      • Send and receive patches by copy and paste
      • apply outside of a Git repository
  14. push and pull
    1. push
      • Automatically create upstream branches with push.autoSetupRemote
      • Force push with safety features
      • Push a commit and its annotated tags with --follow-tags
    2. pull
      • Rebase divergent branches when you pull with pull.rebase
      • Make a branch pull from and push to different remotes
  15. merge and rebase
    1. merge
      • Improve conflict display with the zdiff3 style
      • Open all conflicted files with the edit-unmerged alias
      • Enable rerere to reuse recorded (conflict) resolutions
      • Pick one side of conflicts with git restore or git merge -X
    2. rebase
      • Control rebasing with interactive mode (-i)
      • Top interactive mode actions
      • Squash and rebase a branch with --keep-base
      • Rebase stacked branches with --update-refs
      • Run a command at each step with -x
      • Automatically fix up commits with rebase.autoSquash
      • Drop already-merged commits with --empty drop
  16. log and reflog
    1. log
      • Three levels of detail: --oneline, --stat, and --patch
      • Reveal branching structure with --graph
      • Filter by changes with the pickaxe options -S and -G
      • Filter by commit message content with --grep
      • Restrict time with --since and --until
      • Sort oldest first with --reverse
      • Follow changes to a single file with --follow
      • Follow changes to a code block with -L
      • Reveal hidden changes in merge commits with --cc
    2. reflog
      • reflog basics
      • Restore a deleted branch
      • Undo a commit amendment
      • Undo a bad rebase
  17. blame and bisect
    1. blame
      • blame basics
      • Blame a code block with -L
      • Ignore mass-change commits with blame.ignoreRevsFile
    2. bisect
      • bisect basics
      • Mark a commit as untestable with git bisect skip
      • Automate testing with git bisect run
      • Automate testing of performance regressions
  18. Outroduction
    1. Honourable mentions
      • Git features
      • Extra tools
      • Just for fun
    2. Further reading
      • Git updates
      • Git under the hood
    3. Thank you

Acknowledgements

Many thanks to everyone who has helped me assemble this book.

My gratitude to Linus Torvalds for creating Git, Junio Hamano for maintaining it since 2005, and everyone who has contributed to it. The project is consistently managed and thoroughly documented, so as a stable platform, it’s a joy to use and write about.

Thank you to everyone who has ever written a blog post about Git. I probably read every such post during the research phase and learned a hell of a lot.

Also thanks to the hosts and guests on the two past Git podcasts: Git Minutes and All Things Git. I learned a lot of history trawling the archives.

I’d like to particularly thank all beta and early access readers who gave me feedback: Adrien Cossa, Alex McLarty, Angus Johnson (thanks Dad!), Anthony Sottile, Carles Pina i Estany, Carlton Gibson, Dan O’Leary, Daniel Andrlik, Glenn Dufke, Hugo van Kemenade, James Cooke, Jeroen Janssens, Jonathan Evans, Julius Šėporaitis, Lance Goyke, Ngazetungue Muheue, Pascal Fouque, Rodrigo Girão Serrão, Sage Abdullah, Spark Perreras, Thibaud Colas, and William Berg.

I would also like to thank my dear wife, Mafalda, for helping me find the time to write and prodding me towards the end. And similarly, I am grateful for the support of my parents, brother, sister-in-law, mother-in-law, and extended family.

I thank my baby boy Gerry for looking lovely, especially while sleeping strapped to my chest during the initial authoring process.

And finally, thank you, dear reader, for purchasing this book. I hope you learn some valuable things.

Fin

May your development experience ever improve,

—Adam


Subscribe via RSS, Twitter, Mastodon, or email:

One summary email a week, no spam, I pinky promise.

Related posts:

Tags: