Skip to main content
Version Control · 61 Chapters · 320 Sections · 100+ Professional Recipes

Git Notes & Reference Guide

The definitive developer reference for Git. Master daily commands, advanced history manipulation, branching workflows, disaster recovery with reflog, and the underlying object plumbing. Read every chapter with syntax-highlighted examples, diagrams, and modern workflow recommendations.

Explore All 61 Chapters

Browse by topic or click any chapter to view full explanations, command syntax, and diagrams.

  1. Chapter 01 Getting Started

    Install Git, verify your version, initialize repositories, configure user identity, and manage remotes.

  2. Chapter 02 Browsing History

    Inspect commit histories using git log, formatting, graph visualization, author filters, and date ranges.

  3. Chapter 03 Working with Remotes

    Add, inspect, rename, update, and prune remote repositories and upstream branch tracking.

  4. Chapter 04 Staging

    Stage all changes, individual files, deleted files, unstage modifications, and add hunks interactively.

  5. Chapter 05 Ignoring Files and Folders

    Configure local and global .gitignore patterns, exceptions, subfolder rules, and untrack committed files.

  6. Chapter 06 Git Diff

    Compare working directory changes, staged files, branches, commits, word diffs, and patch generation.

  7. Chapter 07 Undoing

    Roll back commits, undo working copy changes, recover with reflog, and undo merged commits.

  8. Chapter 08 Merging

    Perform automatic merges, fast-forward merges, no-ff commits, merge strategies, and abort merges.

  9. Chapter 09 Submodules

    Clone, initialize, update, move, and remove embedded Git repositories and branch tracking.

  10. Chapter 10 Committing

    Craft clear commit messages, amend commits, stage selectively with patch mode, and sign with GPG.

  11. Chapter 11 Aliases

    Create command shortcuts, complex shell aliases, pretty log graphs, and unwatched file helpers.

  12. Chapter 12 Rebasing

    Rebase local branches, perform interactive rebases to squash or reword commits, and configure autostash.

  13. Chapter 13 Configuration

    Set default editors, auto-correct typos, manage multi-account identities, line endings, and proxies.

  14. Chapter 14 Branching

    Create, switch, list, delete, rename, search, and track local and remote branches.

  15. Chapter 15 Rev-List

    Filter and list commits between branches to verify merges and commit ancestry.

  16. Chapter 16 Squashing

    Combine multiple commits into one using reset, merge --squash, interactive rebase, and autosquash.

  17. Chapter 17 Cherry Picking

    Apply individual commits or commit ranges across branches, check redundancy, and cherry pick clean patches.

  18. Chapter 18 Recovering

    Recover lost commits, dropped stashes, deleted branches, and restored file versions using git reflog.

  19. Chapter 19 Git Clean

    Interactively or forcefully remove untracked files, ignored files, and untracked directories.

  20. Chapter 20 Gitattributes

    Configure automatic line ending normalization, binary file detection, and custom diff drivers.

  21. Chapter 21 Mailmap & Aliases

    Map author names and email aliases in .mailmap to deduplicate contributor statistics in git shortlog.

  22. Chapter 22 Workflows

    Compare Centralized, Gitflow, Feature Branch, GitHub Flow, and Forking collaboration models.

  23. Chapter 23 Pulling

    Fetch and merge remote changes, keep linear history with rebase, overwrite local, and handle permissions.

  24. Chapter 24 Hooks

    Automate pre-commit, commit-msg, pre-push, and post-receive validation scripts on client and server.

  25. Chapter 25 Cloning Repositories

    Execute shallow clones, single-branch clones, recursive submodule clones, and proxy connections.

  26. Chapter 26 Stashing

    Temporarily shelve dirty working directory changes, pop, apply, create partial stashes, and recover dropped stashes.

  27. Chapter 27 Subtrees

    Embed third-party repositories, pull updates, and backport commits using git subtree.

  28. Chapter 28 Renaming

    Rename directories, files, local branches, and remote-tracking branches safely.

  29. Chapter 29 Pushing

    Push branches, tags, specific commits, configure default push behavior, and use force-with-lease.

  30. Chapter 30 Internals

    Understand Git’s object store: blobs, trees, commits, annotated tags, HEAD, and symbolic refs.

  31. Chapter 31 git-tfs

    Bridge Git and Team Foundation Server (TFVS) with clone, checkin, pull, and push workflows.

  32. Chapter 32 Empty Directories

    Work around Git’s file-only tracking model using .gitkeep and directory conventions.

  33. Chapter 33 git-svn

    Interact with Subversion repositories: clone, dcommit, linear rebase, and empty directory tracking.

  34. Chapter 34 Archive

    Export clean zip and tar archives of specific commits, branches, tags, or subdirectories with git archive.

  35. Chapter 35 Rewriting History with filter-branch

    Bulk rewrite commit author names, emails, and dates across repository history.

  36. Chapter 36 Migrating to Git

    Migrate repositories from SVN, Mercurial (hg), and TFVC into Git with complete commit history.

  37. Chapter 37 Show

    Inspect commit details, patch diffs, tree objects, and blob contents using git show.

  38. Chapter 38 Resolving Merge Conflicts

    Identify conflict markers, resolve file collisions manually, and complete the merge commit.

  39. Chapter 39 Bundles

    Package commits and references into offline sneakernet files with git bundle.

  40. Chapter 40 Gitk History Viewer

    Visualize repository DAGs, commit ranges, ancestry paths, and file histories with Gitk.

  41. Chapter 41 Bisecting Faulty Commits

    Locate regression-introducing commits via binary search using manual or automated git bisect.

  42. Chapter 42 Blaming

    Inspect line-by-line file authorship, commit timestamps, line ranges, and ignore whitespace adjustments.

  43. Chapter 43 Git Revisions Syntax

    Master revision specifiers: SHA-1 prefixes, symbolic refs, HEAD^, HEAD~n, ranges, and text searches.

  44. Chapter 44 Worktrees

    Manage multiple working directories attached to the same repository simultaneously with git worktree.

  45. Chapter 45 Git Remote

    List, add, rename, prune, query, and configure URLs for remote tracking repositories.

  46. Chapter 46 Git Large File Storage (LFS)

    Track binary assets and heavy files via external pointers using Git LFS and .gitattributes.

  47. Chapter 47 Git Patch

    Generate email-compatible patches with git format-patch and apply changes cleanly with git apply and git am.

  48. Chapter 48 Git Statistics

    Analyze commit counts, lines of code per author, commit dates, and find local repositories.

  49. Chapter 49 git send-email

    Configure SMTP and send patch series to open source mailing lists using git send-email.

  50. Chapter 50 Git GUI Clients

    Compare built-in tools (gitk, git-gui) with GitHub Desktop, GitKraken, SourceTree, and SmartGit.

  51. Chapter 51 Reflog & Lost Commits

    Recover lost commits after erroneous rebases, accidental resets, or bad squashes using git reflog.

  52. Chapter 52 TortoiseGit

    Perform GUI squashing, assume-unchanged flagging, file ignoring, and branching with TortoiseGit on Windows.

  53. Chapter 53 External Merge & Diff Tools

    Configure external visual diff and merge tools including KDiff3, IntelliJ IDEA, and Beyond Compare.

  54. Chapter 54 Update Object Name in Reference

    Low-level reference updates, validation, and reflog creation using git update-ref.

  55. Chapter 55 Branch Name in Bash Prompt

    Customize PS1 in bash to display the active Git branch dynamically in your terminal prompt.

  56. Chapter 56 Git Client-Side Hooks

    Implement custom pre-push checks, WIP commit blockers, and test suite runners locally.

  57. Chapter 57 Git rerere

    Automate recurring merge conflict resolution across rebases with Reuse Recorded Resolution (rerere).

  58. Chapter 58 Change Git Repository Name

    Update local remote URLs when GitHub or Bitbucket repository names are changed.

  59. Chapter 59 Git Tagging

    Create lightweight and annotated tags, list, search version tags, and push tags to remotes.

  60. Chapter 60 Tidying Local & Remote Repo

    Prune dead remote tracking branches and clean up deleted local branches using git fetch -p.

  61. Chapter 61 Git diff-tree

    Compare tree objects, inspect commit modifications, and format diff output at plumbing level.

Frequently Asked Questions

What does this Git Guide cover?

All 61 chapters and 320 sections from Git Notes for Professionals: installation, branching, interactive rebasing, staging hunks, .gitignore rules, worktrees, reflog recovery, submodules, subtrees, workflows (Gitflow, GitHub Flow, Forking), hooks, and Git internals.

How do I choose between git rebase and git merge?

Use git merge when you want to preserve the complete chronological history including branch merge points. Use git rebase to maintain a clean, linear commit history before integrating feature branches into shared branches like main.

What is the difference between git checkout and git switch / git restore?

In modern Git (v2.23+), the overloaded git checkout command is split into git switch (for creating and switching branches) and git restore (for reverting working tree files and unstaging changes).

Can I recover commits that were accidentally reset or squashed?

Yes! Git maintains a local reference log (git reflog) for approximately 90 days. You can inspect git reflog to locate orphaned commit hashes and recreate branches at those points.

Is this Git handbook free and open?

Yes. The handbook is compiled from Stack Overflow Documentation and released under Creative Commons Attribution-ShareAlike (CC BY-SA 3.0). You can also download the original offline PDF directly.

Contributors & Credits

Original Stack Overflow Documentation contributors, as credited in the source book.

Buy me a coffee
Daily Practice
0/0