From 7cefad6e0542bedac5b43ba1b120fac2711798ad Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 15:06:59 +0000 Subject: [PATCH 01/18] Add CLAUDE.md with project guidance for Claude Code https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- CLAUDE.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 000000000..e9da4ddd9 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,49 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +This is the source repository for **Pro Git, Second Edition** — the official Git book published at https://git-scm.com/book. Content is written in AsciiDoc and built into HTML, PDF, EPUB, Mobi, and FB2 formats using Ruby-based tooling (Asciidoctor). + +## Build Commands + +Requires Ruby 3.1+ and Bundler. Install dependencies first with `bundle install`. + +```bash +bundle exec rake book:build # Build all formats (HTML, EPUB, FB2, Mobi, PDF) +bundle exec rake book:build_html # Build HTML only (fastest, outputs progit.html) +bundle exec rake book:build_epub # Build EPUB only (outputs progit.epub) +bundle exec rake book:build_pdf # Build PDF only (slow, outputs progit.pdf) +bundle exec rake book:build_mobi # Build Mobi/KF8 (outputs progit.mobi) +bundle exec rake book:build_fb2 # Build FB2 (outputs progit.fb2.zip) +bundle exec rake book:clean # Remove all generated files +``` + +## Validation / Testing + +There are no unit tests. Validation checks the generated output formats: + +```bash +bundle exec rake book:check # Builds HTML + EPUB, then runs htmlproofer and epubcheck +``` + +CI runs `bundle exec rake book:build` on pull requests to main. + +## Architecture + +**Entry point:** `progit.asc` — the master document that includes all chapters via AsciiDoc `include::` directives. + +**Content structure:** Each chapter lives in `book/NN-chapter-name/` with a main `.asc` file and a `sections/` subdirectory containing individual topic files. Chapter-level include files (`ch01-getting-started.asc`, etc.) sit at the root and bridge `progit.asc` to the `book/` subdirectories. + +**Themes:** Output format styling is in `theme/` with subdirectories per format (`html/`, `epub/`, `pdf/`, `mobi/`), each containing XSL and CSS files. + +**Images:** Diagrams are in `images/` (PNG/SVG). Source designs are in `diagram-source/progit.sketch`. New figures should be added as pages in the Sketch file, exported at 800w. + +**Build system:** `Rakefile` defines all build tasks. It auto-generates `book/contributors.txt` from git history and embeds version/date info from git tags into builds. + +## Content Guidelines + +- Content is licensed CC-BY-NC-SA-3.0. Contributors agree to this license via PR. +- Small corrections (errata, clarifications) are accepted directly. Large rewrites require an issue for discussion first — professional copy editors have already reviewed the content. +- The book has 10 chapters (01–10), plus 3 appendices (A, B, C). From 26d8cf65238fe6d3b669faed752cdb6bd2b9c65c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 15:16:04 +0000 Subject: [PATCH 02/18] Add licensing and attribution notes for derivative work https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/licensing-and-attribution.md | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 00-notes/licensing-and-attribution.md diff --git a/00-notes/licensing-and-attribution.md b/00-notes/licensing-and-attribution.md new file mode 100644 index 000000000..8fae1cd9b --- /dev/null +++ b/00-notes/licensing-and-attribution.md @@ -0,0 +1,40 @@ +# Licensing & Attribution Notes + +## License: CC-BY-NC-SA-3.0 + +Pro Git, 2nd Edition is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported. This license explicitly allows derivative works under three conditions: + +### 1. Attribution (BY) + +- Credit Scott Chacon and Ben Straub as the original authors +- Link to the original: https://git-scm.com/book/en/v2 +- Indicate that changes were made (rewritten for UX designers, new sections added, etc.) + +### 2. NonCommercial (NC) + +- Cannot use the material for commercial purposes (no selling, no paid courses/products) +- Free distribution, personal use, and educational contexts are fine +- Contact the authors directly for any commercial arrangement + +### 3. ShareAlike (SA) + +- This derivative work must be released under the same license (CC-BY-NC-SA-3.0) or a compatible one +- Cannot make the adapted version more restrictive +- Others may in turn adapt this version under the same terms + +## No Permission Required + +- The CC license pre-authorizes derivative works; no need to ask permission +- The CONTRIBUTING.md rules (open an issue, PR grants rights to @ben and @schacon) apply to contributions back to the original repo, not to independent derivative works +- Letting the authors know is a courteous gesture but not a legal requirement + +## Suggested Attribution Block + +Include in the adapted book's front matter: + +> *Based on Pro Git, 2nd Edition by Scott Chacon and Ben Straub (https://git-scm.com/book/en/v2). Adapted with design-specific examples and content for UX designers. This adaptation is licensed under CC-BY-NC-SA-3.0. Changes were made from the original work.* + +## Original Author Contact (from CITATION.cff) + +- Scott Chacon — schacon@gmail.com +- Ben Straub — ben@straub.cc From 0b2a09287cbec8ad7fbfa76b9e9e64f1ed2e7e21 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 15:18:08 +0000 Subject: [PATCH 03/18] Add working directory convention to CLAUDE.md https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- CLAUDE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index e9da4ddd9..a09b359ff 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,6 +2,10 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. +## Working Directory + +All new files and notes go into the `00-notes/` directory unless explicitly told otherwise. + ## Project Overview This is the source repository for **Pro Git, Second Edition** — the official Git book published at https://git-scm.com/book. Content is written in AsciiDoc and built into HTML, PDF, EPUB, Mobi, and FB2 formats using Ruby-based tooling (Asciidoctor). From b552a96c9e62372da03dcb648932539fbffd1787 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 15:22:23 +0000 Subject: [PATCH 04/18] Add ASCII tree view of original Pro Git table of contents https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/original-toc.md | 138 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 00-notes/original-toc.md diff --git a/00-notes/original-toc.md b/00-notes/original-toc.md new file mode 100644 index 000000000..6d3d6455f --- /dev/null +++ b/00-notes/original-toc.md @@ -0,0 +1,138 @@ +# Pro Git, 2nd Edition — Original Table of Contents + +``` +Pro Git +├── License +├── Preface by Scott Chacon +├── Preface by Ben Straub +├── Dedication +├── Contributors +├── Introduction +│ +├── Ch 1: Getting Started +│ ├── About Version Control +│ ├── A Short History of Git +│ ├── What is Git? +│ ├── The Command Line +│ ├── Installing Git +│ ├── First-Time Git Setup +│ ├── Getting Help +│ └── Summary +│ +├── Ch 2: Git Basics +│ ├── Getting a Git Repository +│ ├── Recording Changes to the Repository +│ ├── Viewing the Commit History +│ ├── Undoing Things +│ ├── Working with Remotes +│ ├── Tagging +│ ├── Git Aliases +│ └── Summary +│ +├── Ch 3: Git Branching +│ ├── Branches in a Nutshell +│ ├── Basic Branching and Merging +│ ├── Branch Management +│ ├── Branching Workflows +│ ├── Remote Branches +│ ├── Rebasing +│ └── Summary +│ +├── Ch 4: Git on the Server +│ ├── The Protocols +│ ├── Getting Git on a Server +│ ├── Generating Your SSH Public Key +│ ├── Setting Up the Server +│ ├── Git Daemon +│ ├── Smart HTTP +│ ├── GitWeb +│ ├── GitLab +│ ├── Third Party Hosted Options +│ └── Summary +│ +├── Ch 5: Distributed Git +│ ├── Distributed Workflows +│ ├── Contributing to a Project +│ ├── Maintaining a Project +│ └── Summary +│ +├── Ch 6: GitHub +│ ├── Account Setup and Configuration +│ ├── Contributing to a Project +│ ├── Maintaining a Project +│ ├── Managing an Organization +│ ├── Scripting GitHub +│ └── Summary +│ +├── Ch 7: Git Tools +│ ├── Revision Selection +│ ├── Interactive Staging +│ ├── Stashing and Cleaning +│ ├── Signing Your Work +│ ├── Searching +│ ├── Rewriting History +│ ├── Reset Demystified +│ ├── Advanced Merging +│ ├── Rerere +│ ├── Debugging with Git +│ ├── Submodules +│ ├── Bundling +│ ├── Replace +│ ├── Credential Storage +│ └── Summary +│ +├── Ch 8: Customizing Git +│ ├── Git Configuration +│ ├── Git Attributes +│ ├── Git Hooks +│ ├── An Example Git-Enforced Policy +│ └── Summary +│ +├── Ch 9: Git and Other Systems +│ ├── Git as a Client +│ ├── Migrating to Git +│ └── Summary +│ +├── Ch 10: Git Internals +│ ├── Plumbing and Porcelain +│ ├── Git Objects +│ ├── Git References +│ ├── Packfiles +│ ├── The Refspec +│ ├── Transfer Protocols +│ ├── Maintenance and Data Recovery +│ ├── Environment Variables +│ └── Summary +│ +├── Appendix A: Git in Other Environments +│ ├── Graphical Interfaces +│ ├── Git in Visual Studio +│ ├── Git in Visual Studio Code +│ ├── Git in IntelliJ / PyCharm / WebStorm / PhpStorm / RubyMine +│ ├── Git in Sublime Text +│ ├── Git in Bash +│ ├── Git in Zsh +│ ├── Git in PowerShell +│ └── Summary +│ +├── Appendix B: Embedding Git in your Applications +│ ├── Command-line Git +│ ├── Libgit2 +│ ├── JGit +│ ├── go-git +│ └── Dulwich +│ +└── Appendix C: Git Commands + ├── Setup and Config + ├── Getting and Creating Projects + ├── Basic Snapshotting + ├── Branching and Merging + ├── Sharing and Updating Projects + ├── Inspection and Comparison + ├── Debugging + ├── Patching + ├── Email + ├── External Systems + ├── Administration + └── Plumbing Commands +``` From b48680746c0ae95df47e07090c0b611cb6b61c64 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 17:32:00 +0000 Subject: [PATCH 05/18] Add per-chapter ASCII tree TOC files for all chapters and appendices 13 files covering Ch 1-10 and Appendices A-C, each with full section and sub-section hierarchy in tree format. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- ...oc-appendix-a-git-in-other-environments.md | 26 ++++++ 00-notes/toc-appendix-b-embedding-git.md | 24 ++++++ 00-notes/toc-appendix-c-git-commands.md | 76 ++++++++++++++++++ 00-notes/toc-ch01-getting-started.md | 36 +++++++++ 00-notes/toc-ch02-git-basics.md | 50 ++++++++++++ 00-notes/toc-ch03-git-branching.md | 35 ++++++++ 00-notes/toc-ch04-git-on-the-server.md | 34 ++++++++ 00-notes/toc-ch05-distributed-git.md | 32 ++++++++ 00-notes/toc-ch06-github.md | 42 ++++++++++ 00-notes/toc-ch07-git-tools.md | 79 +++++++++++++++++++ 00-notes/toc-ch08-customizing-git.md | 28 +++++++ 00-notes/toc-ch09-git-and-other-systems.md | 17 ++++ 00-notes/toc-ch10-git-internals.md | 44 +++++++++++ 13 files changed, 523 insertions(+) create mode 100644 00-notes/toc-appendix-a-git-in-other-environments.md create mode 100644 00-notes/toc-appendix-b-embedding-git.md create mode 100644 00-notes/toc-appendix-c-git-commands.md create mode 100644 00-notes/toc-ch01-getting-started.md create mode 100644 00-notes/toc-ch02-git-basics.md create mode 100644 00-notes/toc-ch03-git-branching.md create mode 100644 00-notes/toc-ch04-git-on-the-server.md create mode 100644 00-notes/toc-ch05-distributed-git.md create mode 100644 00-notes/toc-ch06-github.md create mode 100644 00-notes/toc-ch07-git-tools.md create mode 100644 00-notes/toc-ch08-customizing-git.md create mode 100644 00-notes/toc-ch09-git-and-other-systems.md create mode 100644 00-notes/toc-ch10-git-internals.md diff --git a/00-notes/toc-appendix-a-git-in-other-environments.md b/00-notes/toc-appendix-a-git-in-other-environments.md new file mode 100644 index 000000000..ad08e3ac6 --- /dev/null +++ b/00-notes/toc-appendix-a-git-in-other-environments.md @@ -0,0 +1,26 @@ +# Appendix A: Git in Other Environments + +``` +Git in Other Environments +├── Graphical Interfaces +│ ├── gitk and git-gui +│ ├── GitHub for macOS and Windows +│ └── Other GUIs +│ +├── Git in Visual Studio +│ +├── Git in Visual Studio Code +│ +├── Git in IntelliJ / PyCharm / WebStorm / PhpStorm / RubyMine +│ +├── Git in Sublime Text +│ +├── Git in Bash +│ +├── Git in Zsh +│ +├── Git in PowerShell +│ └── Installation +│ +└── Summary +``` diff --git a/00-notes/toc-appendix-b-embedding-git.md b/00-notes/toc-appendix-b-embedding-git.md new file mode 100644 index 000000000..14117c8f5 --- /dev/null +++ b/00-notes/toc-appendix-b-embedding-git.md @@ -0,0 +1,24 @@ +# Appendix B: Embedding Git in your Applications + +``` +Embedding Git in your Applications +├── Command-line Git +│ +├── Libgit2 +│ ├── Advanced Functionality +│ ├── Other Bindings +│ └── Further Reading +│ +├── JGit +│ ├── Getting Set Up +│ ├── Plumbing +│ ├── Porcelain +│ └── Further Reading +│ +├── go-git +│ ├── Advanced Functionality +│ └── Further Reading +│ +└── Dulwich + └── Further Reading +``` diff --git a/00-notes/toc-appendix-c-git-commands.md b/00-notes/toc-appendix-c-git-commands.md new file mode 100644 index 000000000..345584ccf --- /dev/null +++ b/00-notes/toc-appendix-c-git-commands.md @@ -0,0 +1,76 @@ +# Appendix C: Git Commands + +``` +Git Commands +├── Setup and Config +│ ├── git config +│ ├── git config core.editor commands +│ └── git help +│ +├── Getting and Creating Projects +│ ├── git init +│ └── git clone +│ +├── Basic Snapshotting +│ ├── git add +│ ├── git status +│ ├── git diff +│ ├── git difftool +│ ├── git commit +│ ├── git reset +│ ├── git rm +│ ├── git mv +│ └── git clean +│ +├── Branching and Merging +│ ├── git branch +│ ├── git checkout +│ ├── git merge +│ ├── git mergetool +│ ├── git log +│ ├── git stash +│ └── git tag +│ +├── Sharing and Updating Projects +│ ├── git fetch +│ ├── git pull +│ ├── git push +│ ├── git remote +│ ├── git archive +│ └── git submodule +│ +├── Inspection and Comparison +│ ├── git show +│ ├── git shortlog +│ └── git describe +│ +├── Debugging +│ ├── git bisect +│ ├── git blame +│ └── git grep +│ +├── Patching +│ ├── git cherry-pick +│ ├── git rebase +│ └── git revert +│ +├── Email +│ ├── git apply +│ ├── git am +│ ├── git format-patch +│ ├── git imap-send +│ ├── git send-email +│ └── git request-pull +│ +├── External Systems +│ ├── git svn +│ └── git fast-import +│ +├── Administration +│ ├── git gc +│ ├── git fsck +│ ├── git reflog +│ └── git filter-branch +│ +└── Plumbing Commands +``` diff --git a/00-notes/toc-ch01-getting-started.md b/00-notes/toc-ch01-getting-started.md new file mode 100644 index 000000000..f2ad59b76 --- /dev/null +++ b/00-notes/toc-ch01-getting-started.md @@ -0,0 +1,36 @@ +# Ch 1: Getting Started + +``` +Getting Started +├── About Version Control +│ ├── Local Version Control Systems +│ ├── Centralized Version Control Systems +│ └── Distributed Version Control Systems +│ +├── A Short History of Git +│ +├── What is Git? +│ ├── Snapshots, Not Differences +│ ├── Nearly Every Operation Is Local +│ ├── Git Has Integrity +│ ├── Git Generally Only Adds Data +│ └── The Three States +│ +├── The Command Line +│ +├── Installing Git +│ ├── Installing on Linux +│ ├── Installing on macOS +│ ├── Installing on Windows +│ └── Installing from Source +│ +├── First-Time Git Setup +│ ├── Your Identity +│ ├── Your Editor +│ ├── Your default branch name +│ └── Checking Your Settings +│ +├── Getting Help +│ +└── Summary +``` diff --git a/00-notes/toc-ch02-git-basics.md b/00-notes/toc-ch02-git-basics.md new file mode 100644 index 000000000..aafde7804 --- /dev/null +++ b/00-notes/toc-ch02-git-basics.md @@ -0,0 +1,50 @@ +# Ch 2: Git Basics + +``` +Git Basics +├── Getting a Git Repository +│ ├── Initializing a Repository in an Existing Directory +│ └── Cloning an Existing Repository +│ +├── Recording Changes to the Repository +│ ├── Checking the Status of Your Files +│ ├── Tracking New Files +│ ├── Staging Modified Files +│ ├── Short Status +│ ├── Ignoring Files +│ ├── Viewing Your Staged and Unstaged Changes +│ ├── Committing Your Changes +│ ├── Skipping the Staging Area +│ ├── Removing Files +│ └── Moving Files +│ +├── Viewing the Commit History +│ └── Limiting Log Output +│ +├── Undoing Things +│ ├── Unstaging a Staged File +│ ├── Unmodifying a Modified File +│ └── Undoing things with git restore +│ +├── Working with Remotes +│ ├── Showing Your Remotes +│ ├── Adding Remote Repositories +│ ├── Fetching and Pulling from Your Remotes +│ ├── Pushing to Your Remotes +│ ├── Inspecting a Remote +│ └── Renaming and Removing Remotes +│ +├── Tagging +│ ├── Listing Your Tags +│ ├── Creating Tags +│ ├── Annotated Tags +│ ├── Lightweight Tags +│ ├── Tagging Later +│ ├── Sharing Tags +│ ├── Deleting Tags +│ └── Checking out Tags +│ +├── Git Aliases +│ +└── Summary +``` diff --git a/00-notes/toc-ch03-git-branching.md b/00-notes/toc-ch03-git-branching.md new file mode 100644 index 000000000..3f5d1442a --- /dev/null +++ b/00-notes/toc-ch03-git-branching.md @@ -0,0 +1,35 @@ +# Ch 3: Git Branching + +``` +Git Branching +├── Branches in a Nutshell +│ ├── Creating a New Branch +│ └── Switching Branches +│ +├── Basic Branching and Merging +│ ├── Basic Branching +│ ├── Basic Merging +│ └── Basic Merge Conflicts +│ +├── Branch Management +│ └── Changing a branch name +│ +├── Branching Workflows +│ ├── Long-Running Branches +│ └── Topic Branches +│ +├── Remote Branches +│ ├── Pushing +│ ├── Tracking Branches +│ ├── Pulling +│ └── Deleting Remote Branches +│ +├── Rebasing +│ ├── The Basic Rebase +│ ├── More Interesting Rebases +│ ├── The Perils of Rebasing +│ ├── Rebase When You Rebase +│ └── Rebase vs. Merge +│ +└── Summary +``` diff --git a/00-notes/toc-ch04-git-on-the-server.md b/00-notes/toc-ch04-git-on-the-server.md new file mode 100644 index 000000000..ef6fecb64 --- /dev/null +++ b/00-notes/toc-ch04-git-on-the-server.md @@ -0,0 +1,34 @@ +# Ch 4: Git on the Server + +``` +Git on the Server +├── The Protocols +│ ├── Local Protocol +│ ├── The HTTP Protocols +│ ├── The SSH Protocol +│ └── The Git Protocol +│ +├── Getting Git on a Server +│ ├── Putting the Bare Repository on a Server +│ └── Small Setups +│ +├── Generating Your SSH Public Key +│ +├── Setting Up the Server +│ +├── Git Daemon +│ +├── Smart HTTP +│ +├── GitWeb +│ +├── GitLab +│ ├── Installation +│ ├── Administration +│ ├── Basic Usage +│ └── Working Together +│ +├── Third Party Hosted Options +│ +└── Summary +``` diff --git a/00-notes/toc-ch05-distributed-git.md b/00-notes/toc-ch05-distributed-git.md new file mode 100644 index 000000000..1a6432e26 --- /dev/null +++ b/00-notes/toc-ch05-distributed-git.md @@ -0,0 +1,32 @@ +# Ch 5: Distributed Git + +``` +Distributed Git +├── Distributed Workflows +│ ├── Centralized Workflow +│ ├── Integration-Manager Workflow +│ ├── Dictator and Lieutenants Workflow +│ ├── Patterns for Managing Source Code Branches +│ └── Workflows Summary +│ +├── Contributing to a Project +│ ├── Commit Guidelines +│ ├── Private Small Team +│ ├── Private Managed Team +│ ├── Forked Public Project +│ ├── Public Project over Email +│ └── Summary +│ +├── Maintaining a Project +│ ├── Working in Topic Branches +│ ├── Applying Patches from Email +│ ├── Checking Out Remote Branches +│ ├── Determining What Is Introduced +│ ├── Integrating Contributed Work +│ ├── Tagging Your Releases +│ ├── Generating a Build Number +│ ├── Preparing a Release +│ └── The Shortlog +│ +└── Summary +``` diff --git a/00-notes/toc-ch06-github.md b/00-notes/toc-ch06-github.md new file mode 100644 index 000000000..00a13bdda --- /dev/null +++ b/00-notes/toc-ch06-github.md @@ -0,0 +1,42 @@ +# Ch 6: GitHub + +``` +GitHub +├── Account Setup and Configuration +│ ├── SSH Access +│ ├── Your Avatar +│ ├── Your Email Addresses +│ └── Two Factor Authentication +│ +├── Contributing to a Project +│ ├── Forking Projects +│ ├── The GitHub Flow +│ ├── Advanced Pull Requests +│ ├── GitHub Flavored Markdown +│ └── Keep your GitHub public repository up-to-date +│ +├── Maintaining a Project +│ ├── Creating a New Repository +│ ├── Adding Collaborators +│ ├── Managing Pull Requests +│ ├── Mentions and Notifications +│ ├── Special Files +│ ├── README +│ ├── CONTRIBUTING +│ └── Project Administration +│ +├── Managing an Organization +│ ├── Organization Basics +│ ├── Teams +│ └── Audit Log +│ +├── Scripting GitHub +│ ├── Services and Hooks +│ ├── The GitHub API +│ ├── Basic Usage +│ ├── Commenting on an Issue +│ ├── Changing the Status of a Pull Request +│ └── Octokit +│ +└── Summary +``` diff --git a/00-notes/toc-ch07-git-tools.md b/00-notes/toc-ch07-git-tools.md new file mode 100644 index 000000000..27acf4564 --- /dev/null +++ b/00-notes/toc-ch07-git-tools.md @@ -0,0 +1,79 @@ +# Ch 7: Git Tools + +``` +Git Tools +├── Revision Selection +│ ├── Single Revisions +│ ├── Short SHA-1 +│ ├── Branch References +│ ├── RefLog Shortnames +│ ├── Ancestry References +│ └── Commit Ranges +│ +├── Interactive Staging +│ ├── Staging and Unstaging Files +│ └── Staging Patches +│ +├── Stashing and Cleaning +│ ├── Stashing Your Work +│ ├── Creative Stashing +│ ├── Creating a Branch from a Stash +│ └── Cleaning your Working Directory +│ +├── Signing Your Work +│ ├── GPG Introduction +│ ├── Signing Tags +│ ├── Verifying Tags +│ ├── Signing Commits +│ └── Everyone Must Sign +│ +├── Searching +│ ├── Git Grep +│ └── Git Log Searching +│ +├── Rewriting History +│ ├── Changing the Last Commit +│ ├── Changing Multiple Commit Messages +│ ├── Reordering Commits +│ ├── Squashing Commits +│ ├── Splitting a Commit +│ ├── Deleting a commit +│ └── The Nuclear Option: filter-branch +│ +├── Reset Demystified +│ ├── The Three Trees +│ ├── The Workflow +│ ├── The Role of Reset +│ ├── Reset With a Path +│ ├── Squashing +│ ├── Check It Out +│ └── Summary +│ +├── Advanced Merging +│ ├── Merge Conflicts +│ ├── Undoing Merges +│ └── Other Types of Merges +│ +├── Rerere +│ +├── Debugging with Git +│ ├── File Annotation +│ └── Binary Search +│ +├── Submodules +│ ├── Starting with Submodules +│ ├── Cloning a Project with Submodules +│ ├── Working on a Project with Submodules +│ ├── Submodule Tips +│ └── Issues with Submodules +│ +├── Bundling +│ +├── Replace +│ +├── Credential Storage +│ ├── Under the Hood +│ └── A Custom Credential Cache +│ +└── Summary +``` diff --git a/00-notes/toc-ch08-customizing-git.md b/00-notes/toc-ch08-customizing-git.md new file mode 100644 index 000000000..a94c75902 --- /dev/null +++ b/00-notes/toc-ch08-customizing-git.md @@ -0,0 +1,28 @@ +# Ch 8: Customizing Git + +``` +Customizing Git +├── Git Configuration +│ ├── Basic Client Configuration +│ ├── Colors in Git +│ ├── External Merge and Diff Tools +│ ├── Formatting and Whitespace +│ └── Server Configuration +│ +├── Git Attributes +│ ├── Binary Files +│ ├── Keyword Expansion +│ ├── Exporting Your Repository +│ └── Merge Strategies +│ +├── Git Hooks +│ ├── Installing a Hook +│ ├── Client-Side Hooks +│ └── Server-Side Hooks +│ +├── An Example Git-Enforced Policy +│ ├── Server-Side Hook +│ └── Client-Side Hooks +│ +└── Summary +``` diff --git a/00-notes/toc-ch09-git-and-other-systems.md b/00-notes/toc-ch09-git-and-other-systems.md new file mode 100644 index 000000000..8883c69a6 --- /dev/null +++ b/00-notes/toc-ch09-git-and-other-systems.md @@ -0,0 +1,17 @@ +# Ch 9: Git and Other Systems + +``` +Git and Other Systems +├── Git as a Client +│ ├── Git and Subversion +│ ├── Git and Mercurial +│ └── Git and Perforce +│ +├── Migrating to Git +│ ├── Subversion +│ ├── Mercurial +│ ├── Perforce +│ └── A Custom Importer +│ +└── Summary +``` diff --git a/00-notes/toc-ch10-git-internals.md b/00-notes/toc-ch10-git-internals.md new file mode 100644 index 000000000..6261cfb21 --- /dev/null +++ b/00-notes/toc-ch10-git-internals.md @@ -0,0 +1,44 @@ +# Ch 10: Git Internals + +``` +Git Internals +├── Plumbing and Porcelain +│ +├── Git Objects +│ ├── Tree Objects +│ ├── Commit Objects +│ └── Object Storage +│ +├── Git References +│ ├── The HEAD +│ ├── Tags +│ └── Remotes +│ +├── Packfiles +│ +├── The Refspec +│ ├── Pushing Refspecs +│ └── Deleting References +│ +├── Transfer Protocols +│ ├── The Dumb Protocol +│ ├── The Smart Protocol +│ └── Protocols Summary +│ +├── Maintenance and Data Recovery +│ ├── Maintenance +│ ├── Data Recovery +│ └── Removing Objects +│ +├── Environment Variables +│ ├── Global Behavior +│ ├── Repository Locations +│ ├── Pathspecs +│ ├── Committing +│ ├── Networking +│ ├── Diffing and Merging +│ ├── Debugging +│ └── Miscellaneous +│ +└── Summary +``` From 067d8a6b4ba1cc232e47b4d7fac976bd0aacd230 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Mar 2026 05:33:20 +0000 Subject: [PATCH 06/18] Add content type annotations to all chapter TOC files Established a 12-type lexicon (concept, walkthrough, procedure, reference, history, comparison, diagram, recipe, config, internals, overview, integration) and applied it to every sub-section across all 13 chapter/appendix TOC files. Lexicon documented in content-type-lexicon.md. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/content-type-lexicon.md | 28 ++++++ ...oc-appendix-a-git-in-other-environments.md | 22 ++--- 00-notes/toc-appendix-b-embedding-git.md | 22 ++--- 00-notes/toc-appendix-c-git-commands.md | 98 +++++++++---------- 00-notes/toc-ch01-getting-started.md | 40 ++++---- 00-notes/toc-ch02-git-basics.md | 66 ++++++------- 00-notes/toc-ch03-git-branching.md | 38 +++---- 00-notes/toc-ch04-git-on-the-server.md | 34 +++---- 00-notes/toc-ch05-distributed-git.md | 42 ++++---- 00-notes/toc-ch06-github.md | 54 +++++----- 00-notes/toc-ch07-git-tools.md | 98 +++++++++---------- 00-notes/toc-ch08-customizing-git.md | 30 +++--- 00-notes/toc-ch09-git-and-other-systems.md | 16 +-- 00-notes/toc-ch10-git-internals.md | 52 +++++----- 14 files changed, 334 insertions(+), 306 deletions(-) create mode 100644 00-notes/content-type-lexicon.md diff --git a/00-notes/content-type-lexicon.md b/00-notes/content-type-lexicon.md new file mode 100644 index 000000000..046c4b203 --- /dev/null +++ b/00-notes/content-type-lexicon.md @@ -0,0 +1,28 @@ +# Content Type Lexicon + +This lexicon defines the content type tags used across all chapter TOC files. +Each sub-section is tagged to describe the **primary kind of content** it delivers. + +## Content Types + +| Tag | Meaning | +|--------------|---------------------------------------------------------------------------------------------| +| `concept` | Explains an idea, model, or theory. Answers "what is this?" or "how does this work?" | +| `walkthrough`| Step-by-step narrative that guides the reader through a realistic scenario or workflow | +| `procedure` | Task-oriented instructions: do X, then Y, then Z. Answers "how do I do this?" | +| `reference` | Lookup-oriented listing of options, flags, commands, or settings | +| `history` | Historical narrative or background context about origins and evolution | +| `comparison` | Evaluates alternatives side-by-side, including pros/cons and trade-offs | +| `diagram` | Primarily visual — uses diagrams or figures to explain a model or data structure | +| `recipe` | Short, self-contained example showing a specific technique or tip | +| `config` | Configuration-focused: editing config files, setting options, customizing behavior | +| `internals` | Deep dive into underlying mechanisms, data structures, or protocols | +| `overview` | Brief orientation or survey — introduces a topic area without going deep | +| `integration`| Covers connecting Git with external tools, services, or platforms | + +## Usage Rules + +1. Every sub-section (`====` level) and leaf section (`===` with no children) gets exactly one tag. +2. Parent sections (`===` with children) do **not** get tagged — the children carry the type. +3. When a section blends types, choose the **dominant** one (>50% of content). +4. `Summary` sections at chapter end are tagged `overview` (they recap, not introduce). diff --git a/00-notes/toc-appendix-a-git-in-other-environments.md b/00-notes/toc-appendix-a-git-in-other-environments.md index ad08e3ac6..c4ba189fe 100644 --- a/00-notes/toc-appendix-a-git-in-other-environments.md +++ b/00-notes/toc-appendix-a-git-in-other-environments.md @@ -3,24 +3,24 @@ ``` Git in Other Environments ├── Graphical Interfaces -│ ├── gitk and git-gui -│ ├── GitHub for macOS and Windows -│ └── Other GUIs +│ ├── gitk and git-gui ............................... [overview] +│ ├── GitHub for macOS and Windows ................... [overview] +│ └── Other GUIs ..................................... [overview] │ -├── Git in Visual Studio +├── Git in Visual Studio ............................... [integration] │ -├── Git in Visual Studio Code +├── Git in Visual Studio Code .......................... [integration] │ -├── Git in IntelliJ / PyCharm / WebStorm / PhpStorm / RubyMine +├── Git in IntelliJ / PyCharm / WebStorm / etc. ........ [integration] │ -├── Git in Sublime Text +├── Git in Sublime Text ................................ [integration] │ -├── Git in Bash +├── Git in Bash ........................................ [config] │ -├── Git in Zsh +├── Git in Zsh ......................................... [config] │ ├── Git in PowerShell -│ └── Installation +│ └── Installation ................................... [procedure] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-appendix-b-embedding-git.md b/00-notes/toc-appendix-b-embedding-git.md index 14117c8f5..e630cdfd9 100644 --- a/00-notes/toc-appendix-b-embedding-git.md +++ b/00-notes/toc-appendix-b-embedding-git.md @@ -2,23 +2,23 @@ ``` Embedding Git in your Applications -├── Command-line Git +├── Command-line Git ................................... [concept] │ ├── Libgit2 -│ ├── Advanced Functionality -│ ├── Other Bindings -│ └── Further Reading +│ ├── Advanced Functionality ......................... [walkthrough] +│ ├── Other Bindings ................................. [reference] +│ └── Further Reading ................................ [reference] │ ├── JGit -│ ├── Getting Set Up -│ ├── Plumbing -│ ├── Porcelain -│ └── Further Reading +│ ├── Getting Set Up ................................. [procedure] +│ ├── Plumbing ....................................... [walkthrough] +│ ├── Porcelain ...................................... [walkthrough] +│ └── Further Reading ................................ [reference] │ ├── go-git -│ ├── Advanced Functionality -│ └── Further Reading +│ ├── Advanced Functionality ......................... [walkthrough] +│ └── Further Reading ................................ [reference] │ └── Dulwich - └── Further Reading + └── Further Reading ................................ [reference] ``` diff --git a/00-notes/toc-appendix-c-git-commands.md b/00-notes/toc-appendix-c-git-commands.md index 345584ccf..266ecea54 100644 --- a/00-notes/toc-appendix-c-git-commands.md +++ b/00-notes/toc-appendix-c-git-commands.md @@ -3,74 +3,74 @@ ``` Git Commands ├── Setup and Config -│ ├── git config -│ ├── git config core.editor commands -│ └── git help +│ ├── git config ..................................... [reference] +│ ├── git config core.editor commands ................ [reference] +│ └── git help ....................................... [reference] │ ├── Getting and Creating Projects -│ ├── git init -│ └── git clone +│ ├── git init ....................................... [reference] +│ └── git clone ...................................... [reference] │ ├── Basic Snapshotting -│ ├── git add -│ ├── git status -│ ├── git diff -│ ├── git difftool -│ ├── git commit -│ ├── git reset -│ ├── git rm -│ ├── git mv -│ └── git clean +│ ├── git add ........................................ [reference] +│ ├── git status ..................................... [reference] +│ ├── git diff ....................................... [reference] +│ ├── git difftool ................................... [reference] +│ ├── git commit ..................................... [reference] +│ ├── git reset ...................................... [reference] +│ ├── git rm ......................................... [reference] +│ ├── git mv ......................................... [reference] +│ └── git clean ...................................... [reference] │ ├── Branching and Merging -│ ├── git branch -│ ├── git checkout -│ ├── git merge -│ ├── git mergetool -│ ├── git log -│ ├── git stash -│ └── git tag +│ ├── git branch ..................................... [reference] +│ ├── git checkout ................................... [reference] +│ ├── git merge ...................................... [reference] +│ ├── git mergetool .................................. [reference] +│ ├── git log ........................................ [reference] +│ ├── git stash ...................................... [reference] +│ └── git tag ........................................ [reference] │ ├── Sharing and Updating Projects -│ ├── git fetch -│ ├── git pull -│ ├── git push -│ ├── git remote -│ ├── git archive -│ └── git submodule +│ ├── git fetch ...................................... [reference] +│ ├── git pull ....................................... [reference] +│ ├── git push ....................................... [reference] +│ ├── git remote ..................................... [reference] +│ ├── git archive .................................... [reference] +│ └── git submodule .................................. [reference] │ ├── Inspection and Comparison -│ ├── git show -│ ├── git shortlog -│ └── git describe +│ ├── git show ....................................... [reference] +│ ├── git shortlog ................................... [reference] +│ └── git describe ................................... [reference] │ ├── Debugging -│ ├── git bisect -│ ├── git blame -│ └── git grep +│ ├── git bisect ..................................... [reference] +│ ├── git blame ...................................... [reference] +│ └── git grep ....................................... [reference] │ ├── Patching -│ ├── git cherry-pick -│ ├── git rebase -│ └── git revert +│ ├── git cherry-pick ................................ [reference] +│ ├── git rebase ..................................... [reference] +│ └── git revert ..................................... [reference] │ ├── Email -│ ├── git apply -│ ├── git am -│ ├── git format-patch -│ ├── git imap-send -│ ├── git send-email -│ └── git request-pull +│ ├── git apply ...................................... [reference] +│ ├── git am ......................................... [reference] +│ ├── git format-patch ............................... [reference] +│ ├── git imap-send .................................. [reference] +│ ├── git send-email ................................. [reference] +│ └── git request-pull ............................... [reference] │ ├── External Systems -│ ├── git svn -│ └── git fast-import +│ ├── git svn ........................................ [reference] +│ └── git fast-import ................................ [reference] │ ├── Administration -│ ├── git gc -│ ├── git fsck -│ ├── git reflog -│ └── git filter-branch +│ ├── git gc ......................................... [reference] +│ ├── git fsck ....................................... [reference] +│ ├── git reflog ..................................... [reference] +│ └── git filter-branch .............................. [reference] │ -└── Plumbing Commands +└── Plumbing Commands .................................. [reference] ``` diff --git a/00-notes/toc-ch01-getting-started.md b/00-notes/toc-ch01-getting-started.md index f2ad59b76..98f1d526d 100644 --- a/00-notes/toc-ch01-getting-started.md +++ b/00-notes/toc-ch01-getting-started.md @@ -3,34 +3,34 @@ ``` Getting Started ├── About Version Control -│ ├── Local Version Control Systems -│ ├── Centralized Version Control Systems -│ └── Distributed Version Control Systems +│ ├── Local Version Control Systems .................. [concept] +│ ├── Centralized Version Control Systems ............ [concept] +│ └── Distributed Version Control Systems ............ [concept] │ -├── A Short History of Git +├── A Short History of Git ............................. [history] │ ├── What is Git? -│ ├── Snapshots, Not Differences -│ ├── Nearly Every Operation Is Local -│ ├── Git Has Integrity -│ ├── Git Generally Only Adds Data -│ └── The Three States +│ ├── Snapshots, Not Differences ..................... [concept] +│ ├── Nearly Every Operation Is Local ................ [concept] +│ ├── Git Has Integrity .............................. [concept] +│ ├── Git Generally Only Adds Data ................... [concept] +│ └── The Three States ............................... [diagram] │ -├── The Command Line +├── The Command Line ................................... [overview] │ ├── Installing Git -│ ├── Installing on Linux -│ ├── Installing on macOS -│ ├── Installing on Windows -│ └── Installing from Source +│ ├── Installing on Linux ............................ [procedure] +│ ├── Installing on macOS ............................ [procedure] +│ ├── Installing on Windows .......................... [procedure] +│ └── Installing from Source ......................... [procedure] │ ├── First-Time Git Setup -│ ├── Your Identity -│ ├── Your Editor -│ ├── Your default branch name -│ └── Checking Your Settings +│ ├── Your Identity .................................. [config] +│ ├── Your Editor .................................... [config] +│ ├── Your default branch name ....................... [config] +│ └── Checking Your Settings ......................... [procedure] │ -├── Getting Help +├── Getting Help ....................................... [reference] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch02-git-basics.md b/00-notes/toc-ch02-git-basics.md index aafde7804..488d65815 100644 --- a/00-notes/toc-ch02-git-basics.md +++ b/00-notes/toc-ch02-git-basics.md @@ -3,48 +3,48 @@ ``` Git Basics ├── Getting a Git Repository -│ ├── Initializing a Repository in an Existing Directory -│ └── Cloning an Existing Repository +│ ├── Initializing a Repository in an Existing Directory [procedure] +│ └── Cloning an Existing Repository ................. [procedure] │ ├── Recording Changes to the Repository -│ ├── Checking the Status of Your Files -│ ├── Tracking New Files -│ ├── Staging Modified Files -│ ├── Short Status -│ ├── Ignoring Files -│ ├── Viewing Your Staged and Unstaged Changes -│ ├── Committing Your Changes -│ ├── Skipping the Staging Area -│ ├── Removing Files -│ └── Moving Files +│ ├── Checking the Status of Your Files .............. [walkthrough] +│ ├── Tracking New Files ............................. [walkthrough] +│ ├── Staging Modified Files ......................... [walkthrough] +│ ├── Short Status ................................... [reference] +│ ├── Ignoring Files ................................. [config] +│ ├── Viewing Your Staged and Unstaged Changes ....... [walkthrough] +│ ├── Committing Your Changes ........................ [procedure] +│ ├── Skipping the Staging Area ...................... [recipe] +│ ├── Removing Files ................................. [procedure] +│ └── Moving Files ................................... [procedure] │ -├── Viewing the Commit History -│ └── Limiting Log Output +├── Viewing the Commit History ......................... [walkthrough] +│ └── Limiting Log Output ............................ [reference] │ ├── Undoing Things -│ ├── Unstaging a Staged File -│ ├── Unmodifying a Modified File -│ └── Undoing things with git restore +│ ├── Unstaging a Staged File ........................ [procedure] +│ ├── Unmodifying a Modified File .................... [procedure] +│ └── Undoing things with git restore ................ [procedure] │ ├── Working with Remotes -│ ├── Showing Your Remotes -│ ├── Adding Remote Repositories -│ ├── Fetching and Pulling from Your Remotes -│ ├── Pushing to Your Remotes -│ ├── Inspecting a Remote -│ └── Renaming and Removing Remotes +│ ├── Showing Your Remotes ........................... [procedure] +│ ├── Adding Remote Repositories ..................... [procedure] +│ ├── Fetching and Pulling from Your Remotes ......... [concept] +│ ├── Pushing to Your Remotes ........................ [procedure] +│ ├── Inspecting a Remote ............................ [walkthrough] +│ └── Renaming and Removing Remotes .................. [procedure] │ ├── Tagging -│ ├── Listing Your Tags -│ ├── Creating Tags -│ ├── Annotated Tags -│ ├── Lightweight Tags -│ ├── Tagging Later -│ ├── Sharing Tags -│ ├── Deleting Tags -│ └── Checking out Tags +│ ├── Listing Your Tags .............................. [procedure] +│ ├── Creating Tags .................................. [overview] +│ ├── Annotated Tags ................................. [walkthrough] +│ ├── Lightweight Tags ............................... [walkthrough] +│ ├── Tagging Later .................................. [walkthrough] +│ ├── Sharing Tags ................................... [procedure] +│ ├── Deleting Tags .................................. [procedure] +│ └── Checking out Tags .............................. [procedure] │ -├── Git Aliases +├── Git Aliases ........................................ [recipe] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch03-git-branching.md b/00-notes/toc-ch03-git-branching.md index 3f5d1442a..7d0a5b1a1 100644 --- a/00-notes/toc-ch03-git-branching.md +++ b/00-notes/toc-ch03-git-branching.md @@ -3,33 +3,33 @@ ``` Git Branching ├── Branches in a Nutshell -│ ├── Creating a New Branch -│ └── Switching Branches +│ ├── Creating a New Branch .......................... [diagram] +│ └── Switching Branches ............................. [diagram] │ ├── Basic Branching and Merging -│ ├── Basic Branching -│ ├── Basic Merging -│ └── Basic Merge Conflicts +│ ├── Basic Branching ................................ [walkthrough] +│ ├── Basic Merging .................................. [walkthrough] +│ └── Basic Merge Conflicts .......................... [walkthrough] │ -├── Branch Management -│ └── Changing a branch name +├── Branch Management .................................. [procedure] +│ └── Changing a branch name ......................... [procedure] │ ├── Branching Workflows -│ ├── Long-Running Branches -│ └── Topic Branches +│ ├── Long-Running Branches .......................... [concept] +│ └── Topic Branches ................................. [concept] │ ├── Remote Branches -│ ├── Pushing -│ ├── Tracking Branches -│ ├── Pulling -│ └── Deleting Remote Branches +│ ├── Pushing ........................................ [procedure] +│ ├── Tracking Branches .............................. [procedure] +│ ├── Pulling ........................................ [concept] +│ └── Deleting Remote Branches ....................... [procedure] │ ├── Rebasing -│ ├── The Basic Rebase -│ ├── More Interesting Rebases -│ ├── The Perils of Rebasing -│ ├── Rebase When You Rebase -│ └── Rebase vs. Merge +│ ├── The Basic Rebase ............................... [walkthrough] +│ ├── More Interesting Rebases ....................... [walkthrough] +│ ├── The Perils of Rebasing ......................... [concept] +│ ├── Rebase When You Rebase ......................... [walkthrough] +│ └── Rebase vs. Merge ............................... [comparison] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch04-git-on-the-server.md b/00-notes/toc-ch04-git-on-the-server.md index ef6fecb64..161697bf1 100644 --- a/00-notes/toc-ch04-git-on-the-server.md +++ b/00-notes/toc-ch04-git-on-the-server.md @@ -3,32 +3,32 @@ ``` Git on the Server ├── The Protocols -│ ├── Local Protocol -│ ├── The HTTP Protocols -│ ├── The SSH Protocol -│ └── The Git Protocol +│ ├── Local Protocol ................................. [comparison] +│ ├── The HTTP Protocols ............................. [comparison] +│ ├── The SSH Protocol ............................... [comparison] +│ └── The Git Protocol ............................... [comparison] │ ├── Getting Git on a Server -│ ├── Putting the Bare Repository on a Server -│ └── Small Setups +│ ├── Putting the Bare Repository on a Server ........ [procedure] +│ └── Small Setups ................................... [concept] │ -├── Generating Your SSH Public Key +├── Generating Your SSH Public Key ..................... [procedure] │ -├── Setting Up the Server +├── Setting Up the Server .............................. [procedure] │ -├── Git Daemon +├── Git Daemon ......................................... [config] │ -├── Smart HTTP +├── Smart HTTP ......................................... [config] │ -├── GitWeb +├── GitWeb ............................................. [procedure] │ ├── GitLab -│ ├── Installation -│ ├── Administration -│ ├── Basic Usage -│ └── Working Together +│ ├── Installation ................................... [reference] +│ ├── Administration ................................. [overview] +│ ├── Basic Usage .................................... [walkthrough] +│ └── Working Together ............................... [concept] │ -├── Third Party Hosted Options +├── Third Party Hosted Options ......................... [overview] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch05-distributed-git.md b/00-notes/toc-ch05-distributed-git.md index 1a6432e26..3af2ab5ce 100644 --- a/00-notes/toc-ch05-distributed-git.md +++ b/00-notes/toc-ch05-distributed-git.md @@ -3,30 +3,30 @@ ``` Distributed Git ├── Distributed Workflows -│ ├── Centralized Workflow -│ ├── Integration-Manager Workflow -│ ├── Dictator and Lieutenants Workflow -│ ├── Patterns for Managing Source Code Branches -│ └── Workflows Summary +│ ├── Centralized Workflow ........................... [concept] +│ ├── Integration-Manager Workflow ................... [concept] +│ ├── Dictator and Lieutenants Workflow .............. [concept] +│ ├── Patterns for Managing Source Code Branches ..... [concept] +│ └── Workflows Summary .............................. [overview] │ ├── Contributing to a Project -│ ├── Commit Guidelines -│ ├── Private Small Team -│ ├── Private Managed Team -│ ├── Forked Public Project -│ ├── Public Project over Email -│ └── Summary +│ ├── Commit Guidelines .............................. [concept] +│ ├── Private Small Team ............................. [walkthrough] +│ ├── Private Managed Team ........................... [walkthrough] +│ ├── Forked Public Project .......................... [walkthrough] +│ ├── Public Project over Email ...................... [walkthrough] +│ └── Summary ........................................ [overview] │ ├── Maintaining a Project -│ ├── Working in Topic Branches -│ ├── Applying Patches from Email -│ ├── Checking Out Remote Branches -│ ├── Determining What Is Introduced -│ ├── Integrating Contributed Work -│ ├── Tagging Your Releases -│ ├── Generating a Build Number -│ ├── Preparing a Release -│ └── The Shortlog +│ ├── Working in Topic Branches ...................... [concept] +│ ├── Applying Patches from Email .................... [procedure] +│ ├── Checking Out Remote Branches ................... [procedure] +│ ├── Determining What Is Introduced ................. [procedure] +│ ├── Integrating Contributed Work ................... [walkthrough] +│ ├── Tagging Your Releases .......................... [procedure] +│ ├── Generating a Build Number ...................... [procedure] +│ ├── Preparing a Release ............................ [procedure] +│ └── The Shortlog ................................... [recipe] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch06-github.md b/00-notes/toc-ch06-github.md index 00a13bdda..976d519f1 100644 --- a/00-notes/toc-ch06-github.md +++ b/00-notes/toc-ch06-github.md @@ -3,40 +3,40 @@ ``` GitHub ├── Account Setup and Configuration -│ ├── SSH Access -│ ├── Your Avatar -│ ├── Your Email Addresses -│ └── Two Factor Authentication +│ ├── SSH Access ..................................... [config] +│ ├── Your Avatar .................................... [config] +│ ├── Your Email Addresses ........................... [config] +│ └── Two Factor Authentication ...................... [config] │ ├── Contributing to a Project -│ ├── Forking Projects -│ ├── The GitHub Flow -│ ├── Advanced Pull Requests -│ ├── GitHub Flavored Markdown -│ └── Keep your GitHub public repository up-to-date +│ ├── Forking Projects ............................... [concept] +│ ├── The GitHub Flow ................................ [walkthrough] +│ ├── Advanced Pull Requests ......................... [walkthrough] +│ ├── GitHub Flavored Markdown ....................... [reference] +│ └── Keep your GitHub public repository up-to-date .. [procedure] │ ├── Maintaining a Project -│ ├── Creating a New Repository -│ ├── Adding Collaborators -│ ├── Managing Pull Requests -│ ├── Mentions and Notifications -│ ├── Special Files -│ ├── README -│ ├── CONTRIBUTING -│ └── Project Administration +│ ├── Creating a New Repository ...................... [procedure] +│ ├── Adding Collaborators ........................... [procedure] +│ ├── Managing Pull Requests ......................... [walkthrough] +│ ├── Mentions and Notifications ..................... [concept] +│ ├── Special Files .................................. [overview] +│ ├── README ......................................... [concept] +│ ├── CONTRIBUTING ................................... [concept] +│ └── Project Administration ......................... [procedure] │ ├── Managing an Organization -│ ├── Organization Basics -│ ├── Teams -│ └── Audit Log +│ ├── Organization Basics ............................ [overview] +│ ├── Teams .......................................... [walkthrough] +│ └── Audit Log ...................................... [overview] │ ├── Scripting GitHub -│ ├── Services and Hooks -│ ├── The GitHub API -│ ├── Basic Usage -│ ├── Commenting on an Issue -│ ├── Changing the Status of a Pull Request -│ └── Octokit +│ ├── Services and Hooks ............................. [integration] +│ ├── The GitHub API ................................. [overview] +│ ├── Basic Usage .................................... [walkthrough] +│ ├── Commenting on an Issue ......................... [walkthrough] +│ ├── Changing the Status of a Pull Request .......... [walkthrough] +│ └── Octokit ........................................ [integration] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch07-git-tools.md b/00-notes/toc-ch07-git-tools.md index 27acf4564..9bd79746f 100644 --- a/00-notes/toc-ch07-git-tools.md +++ b/00-notes/toc-ch07-git-tools.md @@ -3,77 +3,77 @@ ``` Git Tools ├── Revision Selection -│ ├── Single Revisions -│ ├── Short SHA-1 -│ ├── Branch References -│ ├── RefLog Shortnames -│ ├── Ancestry References -│ └── Commit Ranges +│ ├── Single Revisions ............................... [concept] +│ ├── Short SHA-1 .................................... [concept] +│ ├── Branch References .............................. [concept] +│ ├── RefLog Shortnames .............................. [reference] +│ ├── Ancestry References ............................ [reference] +│ └── Commit Ranges .................................. [reference] │ ├── Interactive Staging -│ ├── Staging and Unstaging Files -│ └── Staging Patches +│ ├── Staging and Unstaging Files .................... [walkthrough] +│ └── Staging Patches ................................ [walkthrough] │ ├── Stashing and Cleaning -│ ├── Stashing Your Work -│ ├── Creative Stashing -│ ├── Creating a Branch from a Stash -│ └── Cleaning your Working Directory +│ ├── Stashing Your Work ............................. [walkthrough] +│ ├── Creative Stashing .............................. [recipe] +│ ├── Creating a Branch from a Stash ................. [recipe] +│ └── Cleaning your Working Directory ................ [procedure] │ ├── Signing Your Work -│ ├── GPG Introduction -│ ├── Signing Tags -│ ├── Verifying Tags -│ ├── Signing Commits -│ └── Everyone Must Sign +│ ├── GPG Introduction ............................... [concept] +│ ├── Signing Tags ................................... [procedure] +│ ├── Verifying Tags ................................. [procedure] +│ ├── Signing Commits ................................ [procedure] +│ └── Everyone Must Sign ............................. [concept] │ ├── Searching -│ ├── Git Grep -│ └── Git Log Searching +│ ├── Git Grep ....................................... [walkthrough] +│ └── Git Log Searching .............................. [walkthrough] │ ├── Rewriting History -│ ├── Changing the Last Commit -│ ├── Changing Multiple Commit Messages -│ ├── Reordering Commits -│ ├── Squashing Commits -│ ├── Splitting a Commit -│ ├── Deleting a commit -│ └── The Nuclear Option: filter-branch +│ ├── Changing the Last Commit ....................... [procedure] +│ ├── Changing Multiple Commit Messages .............. [walkthrough] +│ ├── Reordering Commits ............................. [procedure] +│ ├── Squashing Commits .............................. [walkthrough] +│ ├── Splitting a Commit ............................. [walkthrough] +│ ├── Deleting a commit .............................. [procedure] +│ └── The Nuclear Option: filter-branch .............. [procedure] │ ├── Reset Demystified -│ ├── The Three Trees -│ ├── The Workflow -│ ├── The Role of Reset -│ ├── Reset With a Path -│ ├── Squashing -│ ├── Check It Out -│ └── Summary +│ ├── The Three Trees ................................ [diagram] +│ ├── The Workflow ................................... [walkthrough] +│ ├── The Role of Reset .............................. [internals] +│ ├── Reset With a Path .............................. [internals] +│ ├── Squashing ...................................... [recipe] +│ ├── Check It Out ................................... [comparison] +│ └── Summary ........................................ [reference] │ ├── Advanced Merging -│ ├── Merge Conflicts -│ ├── Undoing Merges -│ └── Other Types of Merges +│ ├── Merge Conflicts ................................ [walkthrough] +│ ├── Undoing Merges ................................. [procedure] +│ └── Other Types of Merges .......................... [reference] │ -├── Rerere +├── Rerere ............................................. [walkthrough] │ ├── Debugging with Git -│ ├── File Annotation -│ └── Binary Search +│ ├── File Annotation ................................ [walkthrough] +│ └── Binary Search .................................. [walkthrough] │ ├── Submodules -│ ├── Starting with Submodules -│ ├── Cloning a Project with Submodules -│ ├── Working on a Project with Submodules -│ ├── Submodule Tips -│ └── Issues with Submodules +│ ├── Starting with Submodules ....................... [walkthrough] +│ ├── Cloning a Project with Submodules .............. [procedure] +│ ├── Working on a Project with Submodules ........... [walkthrough] +│ ├── Submodule Tips ................................. [recipe] +│ └── Issues with Submodules ......................... [concept] │ -├── Bundling +├── Bundling ........................................... [walkthrough] │ -├── Replace +├── Replace ............................................ [walkthrough] │ ├── Credential Storage -│ ├── Under the Hood -│ └── A Custom Credential Cache +│ ├── Under the Hood ................................. [internals] +│ └── A Custom Credential Cache ...................... [walkthrough] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch08-customizing-git.md b/00-notes/toc-ch08-customizing-git.md index a94c75902..42369fb86 100644 --- a/00-notes/toc-ch08-customizing-git.md +++ b/00-notes/toc-ch08-customizing-git.md @@ -3,26 +3,26 @@ ``` Customizing Git ├── Git Configuration -│ ├── Basic Client Configuration -│ ├── Colors in Git -│ ├── External Merge and Diff Tools -│ ├── Formatting and Whitespace -│ └── Server Configuration +│ ├── Basic Client Configuration ..................... [reference] +│ ├── Colors in Git .................................. [config] +│ ├── External Merge and Diff Tools .................. [walkthrough] +│ ├── Formatting and Whitespace ...................... [config] +│ └── Server Configuration ........................... [reference] │ ├── Git Attributes -│ ├── Binary Files -│ ├── Keyword Expansion -│ ├── Exporting Your Repository -│ └── Merge Strategies +│ ├── Binary Files ................................... [config] +│ ├── Keyword Expansion .............................. [walkthrough] +│ ├── Exporting Your Repository ...................... [config] +│ └── Merge Strategies ............................... [config] │ ├── Git Hooks -│ ├── Installing a Hook -│ ├── Client-Side Hooks -│ └── Server-Side Hooks +│ ├── Installing a Hook .............................. [procedure] +│ ├── Client-Side Hooks .............................. [reference] +│ └── Server-Side Hooks .............................. [reference] │ ├── An Example Git-Enforced Policy -│ ├── Server-Side Hook -│ └── Client-Side Hooks +│ ├── Server-Side Hook ............................... [walkthrough] +│ └── Client-Side Hooks .............................. [walkthrough] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch09-git-and-other-systems.md b/00-notes/toc-ch09-git-and-other-systems.md index 8883c69a6..41a404226 100644 --- a/00-notes/toc-ch09-git-and-other-systems.md +++ b/00-notes/toc-ch09-git-and-other-systems.md @@ -3,15 +3,15 @@ ``` Git and Other Systems ├── Git as a Client -│ ├── Git and Subversion -│ ├── Git and Mercurial -│ └── Git and Perforce +│ ├── Git and Subversion ............................. [integration] +│ ├── Git and Mercurial .............................. [integration] +│ └── Git and Perforce ............................... [integration] │ ├── Migrating to Git -│ ├── Subversion -│ ├── Mercurial -│ ├── Perforce -│ └── A Custom Importer +│ ├── Subversion ..................................... [procedure] +│ ├── Mercurial ...................................... [procedure] +│ ├── Perforce ....................................... [procedure] +│ └── A Custom Importer .............................. [walkthrough] │ -└── Summary +└── Summary ............................................ [overview] ``` diff --git a/00-notes/toc-ch10-git-internals.md b/00-notes/toc-ch10-git-internals.md index 6261cfb21..ec1d4869b 100644 --- a/00-notes/toc-ch10-git-internals.md +++ b/00-notes/toc-ch10-git-internals.md @@ -2,43 +2,43 @@ ``` Git Internals -├── Plumbing and Porcelain +├── Plumbing and Porcelain ............................. [concept] │ ├── Git Objects -│ ├── Tree Objects -│ ├── Commit Objects -│ └── Object Storage +│ ├── Tree Objects ................................... [internals] +│ ├── Commit Objects ................................. [internals] +│ └── Object Storage ................................. [internals] │ ├── Git References -│ ├── The HEAD -│ ├── Tags -│ └── Remotes +│ ├── The HEAD ....................................... [internals] +│ ├── Tags ........................................... [internals] +│ └── Remotes ........................................ [internals] │ -├── Packfiles +├── Packfiles .......................................... [internals] │ ├── The Refspec -│ ├── Pushing Refspecs -│ └── Deleting References +│ ├── Pushing Refspecs ............................... [reference] +│ └── Deleting References ............................ [reference] │ ├── Transfer Protocols -│ ├── The Dumb Protocol -│ ├── The Smart Protocol -│ └── Protocols Summary +│ ├── The Dumb Protocol .............................. [internals] +│ ├── The Smart Protocol ............................. [internals] +│ └── Protocols Summary .............................. [overview] │ ├── Maintenance and Data Recovery -│ ├── Maintenance -│ ├── Data Recovery -│ └── Removing Objects +│ ├── Maintenance .................................... [internals] +│ ├── Data Recovery .................................. [walkthrough] +│ └── Removing Objects ............................... [walkthrough] │ ├── Environment Variables -│ ├── Global Behavior -│ ├── Repository Locations -│ ├── Pathspecs -│ ├── Committing -│ ├── Networking -│ ├── Diffing and Merging -│ ├── Debugging -│ └── Miscellaneous -│ -└── Summary +│ ├── Global Behavior ................................ [reference] +│ ├── Repository Locations ........................... [reference] +│ ├── Pathspecs ...................................... [reference] +│ ├── Committing ..................................... [reference] +│ ├── Networking ..................................... [reference] +│ ├── Diffing and Merging ............................ [reference] +│ ├── Debugging ...................................... [reference] +│ └── Miscellaneous .................................. [reference] +│ +└── Summary ............................................ [overview] ``` From 75dc08db005dfb633fe789de24d5e5ef4b2a4218 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Mar 2026 12:48:39 +0000 Subject: [PATCH 07/18] Add walkthroughs.md catalog for all chapters and appendices Create per-chapter directories in 00-notes/ with walkthroughs.md files documenting every walkthrough across the book. Each entry includes the section title, source file, topic, scenario description, and word count. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/01-introduction/walkthroughs.md | 49 ++++ 00-notes/02-git-basics/walkthroughs.md | 199 +++++++++++++++ 00-notes/03-git-branching/walkthroughs.md | 61 +++++ 00-notes/04-git-server/walkthroughs.md | 37 +++ 00-notes/05-distributed-git/walkthroughs.md | 73 ++++++ 00-notes/06-github/walkthroughs.md | 55 +++++ 00-notes/07-git-tools/walkthroughs.md | 229 ++++++++++++++++++ 00-notes/08-customizing-git/walkthroughs.md | 67 +++++ .../09-git-and-other-scms/walkthroughs.md | 133 ++++++++++ 00-notes/10-git-internals/walkthroughs.md | 103 ++++++++ .../walkthroughs.md | 49 ++++ 00-notes/B-embedding-git/walkthroughs.md | 25 ++ 00-notes/C-git-commands/walkthroughs.md | 3 + 13 files changed, 1083 insertions(+) create mode 100644 00-notes/01-introduction/walkthroughs.md create mode 100644 00-notes/02-git-basics/walkthroughs.md create mode 100644 00-notes/03-git-branching/walkthroughs.md create mode 100644 00-notes/04-git-server/walkthroughs.md create mode 100644 00-notes/05-distributed-git/walkthroughs.md create mode 100644 00-notes/06-github/walkthroughs.md create mode 100644 00-notes/07-git-tools/walkthroughs.md create mode 100644 00-notes/08-customizing-git/walkthroughs.md create mode 100644 00-notes/09-git-and-other-scms/walkthroughs.md create mode 100644 00-notes/10-git-internals/walkthroughs.md create mode 100644 00-notes/A-git-in-other-environments/walkthroughs.md create mode 100644 00-notes/B-embedding-git/walkthroughs.md create mode 100644 00-notes/C-git-commands/walkthroughs.md diff --git a/00-notes/01-introduction/walkthroughs.md b/00-notes/01-introduction/walkthroughs.md new file mode 100644 index 000000000..b6e65d369 --- /dev/null +++ b/00-notes/01-introduction/walkthroughs.md @@ -0,0 +1,49 @@ +# Chapter 1: Getting Started — Walkthroughs + +## 1. Your Identity +- **File:** `book/01-introduction/sections/first-time-setup.asc` +- **Topic:** Configuring Git user identity for the first time +- **Scenario:** Reader sets their name and email globally using `git config --global`, with a note on per-project overrides +- **Word Count:** 144 + +## 2. Your Editor +- **File:** `book/01-introduction/sections/first-time-setup.asc` +- **Topic:** Configuring a default text editor for Git +- **Scenario:** Reader configures Git to use their preferred editor (Emacs, Notepad++), with platform-specific command examples +- **Word Count:** 198 + +## 3. Your Default Branch Name +- **File:** `book/01-introduction/sections/first-time-setup.asc` +- **Topic:** Changing the default branch name from "master" to "main" +- **Scenario:** Reader runs `git config --global init.defaultBranch main` to change the default +- **Word Count:** 51 + +## 4. Installing on Linux +- **File:** `book/01-introduction/sections/installing.asc` +- **Topic:** Installing Git on Linux via package managers +- **Scenario:** Reader installs Git using `dnf` (Fedora/RHEL) or `apt` (Debian/Ubuntu) with the appropriate package manager commands +- **Word Count:** 92 + +## 5. Installing on macOS +- **File:** `book/01-introduction/sections/installing.asc` +- **Topic:** Installing Git on macOS +- **Scenario:** Reader triggers the Xcode Command Line Tools installer by running `git` from Terminal, with an alternative binary installer option +- **Word Count:** 107 + +## 6. Installing on Windows +- **File:** `book/01-introduction/sections/installing.asc` +- **Topic:** Installing Git on Windows +- **Scenario:** Reader downloads Git from the official website or installs via the Chocolatey package manager +- **Word Count:** 81 + +## 7. Installing from Source +- **File:** `book/01-introduction/sections/installing.asc` +- **Topic:** Compiling and installing Git from source code +- **Scenario:** Reader installs build dependencies for their distribution, downloads Git source, and compiles/installs with `make` and `make install` +- **Word Count:** 267 + +## 8. Getting Help +- **File:** `book/01-introduction/sections/help.asc` +- **Topic:** Accessing Git command documentation +- **Scenario:** Reader uses three equivalent methods (`git help `, `git --help`, `man git-`) to access help, with a concrete example using `git config` +- **Word Count:** 118 diff --git a/00-notes/02-git-basics/walkthroughs.md b/00-notes/02-git-basics/walkthroughs.md new file mode 100644 index 000000000..9c8223401 --- /dev/null +++ b/00-notes/02-git-basics/walkthroughs.md @@ -0,0 +1,199 @@ +# Chapter 2: Git Basics — Walkthroughs + +## 1. Initializing a Repository in an Existing Directory +- **File:** `book/02-git-basics/sections/getting-a-repository.asc` +- **Topic:** Creating a new Git repository from an existing project +- **Scenario:** Reader navigates to a project directory (with platform-specific paths for Linux, macOS, Windows), runs `git init`, then stages and commits initial files +- **Word Count:** 271 + +## 2. Cloning an Existing Repository +- **File:** `book/02-git-basics/sections/getting-a-repository.asc` +- **Topic:** Cloning a remote repository +- **Scenario:** Reader clones the libgit2 repository using `git clone`, then clones again into a custom-named directory +- **Word Count:** 207 + +## 3. Checking the Status of Your Files +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Tracking file status in a repository +- **Scenario:** Reader runs `git status` after a fresh clone, creates a README file, and observes the status change from clean to untracked +- **Word Count:** 169 + +## 4. Tracking New Files +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Adding untracked files to Git +- **Scenario:** Reader stages a new README file with `git add` and verifies the status change to staged +- **Word Count:** 121 + +## 5. Staging Modified Files +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Understanding the staging workflow for modified files +- **Scenario:** Reader modifies a tracked file, stages it with `git add`, makes further edits, and discovers that Git stages only the version at `git add` time — requiring re-staging +- **Word Count:** 326 + +## 6. Short Status +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Compact status output +- **Scenario:** Reader uses `git status -s` to view two-column status indicators for staging area and working directory +- **Word Count:** 76 + +## 7. Viewing Your Staged and Unstaged Changes +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Inspecting differences before committing +- **Scenario:** Reader uses `git diff` for unstaged changes and `git diff --staged` for staged changes, including a scenario with both staged and unstaged portions of the same file +- **Word Count:** 380 + +## 8. Committing Your Changes +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Creating commits +- **Scenario:** Reader commits using both the editor-based `git commit` and inline `git commit -m` workflows, seeing editor output and commit confirmation +- **Word Count:** 235 + +## 9. Skipping the Staging Area +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Committing without explicit staging +- **Scenario:** Reader uses `git commit -a` to bypass the staging area, automatically staging all tracked files before committing +- **Word Count:** 94 + +## 10. Removing Files +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Removing files from Git tracking +- **Scenario:** Reader manually deletes a file and observes the status, then uses `git rm` to stage the removal, and `git rm --cached` to keep the file locally while removing it from tracking +- **Word Count:** 256 + +## 11. Moving Files +- **File:** `book/02-git-basics/sections/recording-changes.asc` +- **Topic:** Renaming files in Git +- **Scenario:** Reader renames a file with `git mv`, observes the rename status, and learns it is equivalent to manual move + remove + add +- **Word Count:** 187 + +## 12. Adding Remote Repositories +- **File:** `book/02-git-basics/sections/remotes.asc` +- **Topic:** Configuring remote repositories +- **Scenario:** Reader adds a new remote shortname (`pb`) with `git remote add`, verifies with `git remote -v`, and fetches from it +- **Word Count:** 212 + +## 13. Pushing to Your Remotes +- **File:** `book/02-git-basics/sections/remotes.asc` +- **Topic:** Pushing commits to a remote server +- **Scenario:** Reader pushes to origin/master with `git push` and learns when pushes succeed or fail due to upstream changes +- **Word Count:** 126 + +## 14. Inspecting a Remote +- **File:** `book/02-git-basics/sections/remotes.asc` +- **Topic:** Viewing detailed remote information +- **Scenario:** Reader uses `git remote show ` on both a simple case and a complex multi-branch project with tracking configurations +- **Word Count:** 268 + +## 15. Renaming and Removing Remotes +- **File:** `book/02-git-basics/sections/remotes.asc` +- **Topic:** Managing remote shortnames +- **Scenario:** Reader renames a remote with `git remote rename` and deletes one with `git remote remove`, verifying status after each +- **Word Count:** 143 + +## 16. Annotated Tags +- **File:** `book/02-git-basics/sections/tagging.asc` +- **Topic:** Creating annotated tags +- **Scenario:** Reader creates an annotated tag with `git tag -a` and `-m`, then inspects metadata and commit info with `git show` +- **Word Count:** 178 + +## 17. Lightweight Tags +- **File:** `book/02-git-basics/sections/tagging.asc` +- **Topic:** Creating lightweight tags +- **Scenario:** Reader creates a lightweight tag (no `-a`, `-s`, or `-m`) and compares the `git show` output to annotated tags +- **Word Count:** 145 + +## 18. Tagging Later +- **File:** `book/02-git-basics/sections/tagging.asc` +- **Topic:** Retroactively tagging past commits +- **Scenario:** Reader views `git log` output, tags an old commit by hash, and verifies with `git tag` and `git show` +- **Word Count:** 223 + +## 19. Sharing Tags +- **File:** `book/02-git-basics/sections/tagging.asc` +- **Topic:** Pushing tags to remote servers +- **Scenario:** Reader pushes a single tag with `git push origin ` and all tags with `git push origin --tags` +- **Word Count:** 159 + +## 20. Deleting Tags +- **File:** `book/02-git-basics/sections/tagging.asc` +- **Topic:** Removing tags locally and remotely +- **Scenario:** Reader deletes a local tag with `git tag -d`, then removes a remote tag using both `git push :refs/tags/` and `git push --delete` syntax +- **Word Count:** 148 + +## 21. Checking out Tags +- **File:** `book/02-git-basics/sections/tagging.asc` +- **Topic:** Checking out code at a tag +- **Scenario:** Reader checks out a tag with `git checkout`, learns about detached HEAD state, and creates a branch from a tag with `git checkout -b` +- **Word Count:** 212 + +## 22. Undoing a Commit with --amend +- **File:** `book/02-git-basics/sections/undoing.asc` +- **Topic:** Amending the last commit +- **Scenario:** Reader commits too early, then stages forgotten files and uses `git commit --amend` to replace the previous commit +- **Word Count:** 189 + +## 23. Unstaging a Staged File (git reset) +- **File:** `book/02-git-basics/sections/undoing.asc` +- **Topic:** Unstaging files with git reset +- **Scenario:** Reader uses `git reset HEAD ` to unstage a file, with status output before and after +- **Word Count:** 142 + +## 24. Unmodifying a Modified File (git checkout) +- **File:** `book/02-git-basics/sections/undoing.asc` +- **Topic:** Discarding working directory changes +- **Scenario:** Reader uses `git checkout -- ` to revert a modified file, with status verification +- **Word Count:** 131 + +## 25. Unstaging a Staged File with git restore +- **File:** `book/02-git-basics/sections/undoing.asc` +- **Topic:** Unstaging files with the modern git restore command +- **Scenario:** Reader uses `git restore --staged ` as the modern alternative to `git reset` for unstaging +- **Word Count:** 139 + +## 26. Unmodifying a Modified File with git restore +- **File:** `book/02-git-basics/sections/undoing.asc` +- **Topic:** Discarding changes with git restore +- **Scenario:** Reader uses `git restore ` as the modern alternative to `git checkout --` for discarding changes +- **Word Count:** 124 + +## 27. Viewing the Commit History +- **File:** `book/02-git-basics/sections/viewing-history.asc` +- **Topic:** Basic commit history viewing +- **Scenario:** Reader clones a simple project and runs `git log` to view commit history with author, date, and message +- **Word Count:** 142 + +## 28. Using git log -p (Patch View) +- **File:** `book/02-git-basics/sections/viewing-history.asc` +- **Topic:** Viewing diffs in commit history +- **Scenario:** Reader uses `git log -p -2` to show the last two commits with full diffs for code review +- **Word Count:** 121 + +## 29. Using git log --stat +- **File:** `book/02-git-basics/sections/viewing-history.asc` +- **Topic:** Abbreviated change statistics per commit +- **Scenario:** Reader uses `git log --stat` to see file change counts and insertion/deletion summaries +- **Word Count:** 100 + +## 30. Using git log --pretty +- **File:** `book/02-git-basics/sections/viewing-history.asc` +- **Topic:** Custom log output formatting +- **Scenario:** Reader uses `--pretty=oneline` and `--pretty=format:` with custom format strings to tailor log output +- **Word Count:** 174 + +## 31. Using git log --graph +- **File:** `book/02-git-basics/sections/viewing-history.asc` +- **Topic:** Visualizing branch and merge history +- **Scenario:** Reader uses `--pretty=format` combined with `--graph` to display an ASCII graph of branch history +- **Word Count:** 90 + +## 32. Limiting Log Output with Time Filters +- **File:** `book/02-git-basics/sections/viewing-history.asc` +- **Topic:** Time-based commit filtering +- **Scenario:** Reader uses `git log --since` with various date formats to filter commits by time range +- **Word Count:** 93 + +## 33. Filtering Commits by Author and Content +- **File:** `book/02-git-basics/sections/viewing-history.asc` +- **Topic:** Advanced commit filtering with pickaxe and multi-filter queries +- **Scenario:** Reader uses `git log -S` to find commits changing a specific string, and combines author, date, and path filters +- **Word Count:** 208 diff --git a/00-notes/03-git-branching/walkthroughs.md b/00-notes/03-git-branching/walkthroughs.md new file mode 100644 index 000000000..ba4568536 --- /dev/null +++ b/00-notes/03-git-branching/walkthroughs.md @@ -0,0 +1,61 @@ +# Chapter 3: Git Branching — Walkthroughs + +## 1. Basic Branching +- **File:** `book/03-git-branching/sections/basic-branching-and-merging.asc` +- **Topic:** Creating and switching between feature and hotfix branches +- **Scenario:** Reader creates an `iss53` feature branch, receives an urgent bug report, switches to a `hotfix` branch on production, tests and merges the fix, then returns to the original feature work +- **Word Count:** 1,247 + +## 2. Basic Merging +- **File:** `book/03-git-branching/sections/basic-branching-and-merging.asc` +- **Topic:** Merging a completed feature branch with a three-way merge +- **Scenario:** Reader merges the completed `iss53` branch back into master, observing the three-way merge process, and cleans up the branch +- **Word Count:** 418 + +## 3. Basic Merge Conflicts +- **File:** `book/03-git-branching/sections/basic-branching-and-merging.asc` +- **Topic:** Resolving merge conflicts when two branches modify the same file +- **Scenario:** Reader encounters conflict markers after merging, uses `git mergetool` to resolve them, and finalizes with a commit +- **Word Count:** 1,036 + +## 4. The Basic Rebase +- **File:** `book/03-git-branching/sections/rebasing.asc` +- **Topic:** Rebasing a branch onto another +- **Scenario:** Reader rebases an `experiment` branch onto `master`, rewinding and replaying commits, then completes a fast-forward merge +- **Word Count:** 697 + +## 5. More Interesting Rebases +- **File:** `book/03-git-branching/sections/rebasing.asc` +- **Topic:** Selective rebasing with `--onto` +- **Scenario:** Reader selectively rebases `client` and `server` topic branches using `--onto`, integrating changes into mainline in stages +- **Word Count:** 1,123 + +## 6. Pushing Branches +- **File:** `book/03-git-branching/sections/remote-branches.asc` +- **Topic:** Pushing local branches to a remote repository +- **Scenario:** Reader pushes a local `serverfix` branch to a remote, and collaborators fetch and create tracking branches from it +- **Word Count:** 742 + +## 7. Tracking Branches +- **File:** `book/03-git-branching/sections/remote-branches.asc` +- **Topic:** Setting up and managing tracking branches +- **Scenario:** Reader sets up tracking branches using `-b`, `--track`, and implicit creation, checks tracking status with `-vv`, and sets upstream branches +- **Word Count:** 1,261 + +## 8. Deleting Remote Branches +- **File:** `book/03-git-branching/sections/remote-branches.asc` +- **Topic:** Removing branches from a remote server +- **Scenario:** Reader deletes the `serverfix` remote branch using `git push --delete` +- **Word Count:** 168 + +## 9. Changing a Branch Name +- **File:** `book/03-git-branching/sections/branch-management.asc` +- **Topic:** Renaming a local branch and updating the remote +- **Scenario:** Reader renames a local branch, pushes the renamed branch to the remote, and cleans up the old remote branch name +- **Word Count:** 465 + +## 10. Changing the Master Branch Name +- **File:** `book/03-git-branching/sections/branch-management.asc` +- **Topic:** Renaming the master branch to main +- **Scenario:** Reader renames master to main, pushes to remote, and handles follow-up tasks across dependent projects, CI configs, tests, and documentation +- **Word Count:** 837 diff --git a/00-notes/04-git-server/walkthroughs.md b/00-notes/04-git-server/walkthroughs.md new file mode 100644 index 000000000..f3a3d585f --- /dev/null +++ b/00-notes/04-git-server/walkthroughs.md @@ -0,0 +1,37 @@ +# Chapter 4: Git on the Server — Walkthroughs + +## 1. Generating Your SSH Public Key +- **File:** `book/04-git-server/sections/generating-ssh-key.asc` +- **Topic:** Creating SSH key pairs for Git server authentication +- **Scenario:** Reader checks for existing SSH keys in `~/.ssh`, generates a new RSA key pair using `ssh-keygen -o`, sets a passphrase, and learns about the resulting key files +- **Word Count:** 417 + +## 2. Putting the Bare Repository on a Server +- **File:** `book/04-git-server/sections/git-on-a-server.asc` +- **Topic:** Creating and deploying a bare repository for team collaboration +- **Scenario:** Reader clones a local repository with `--bare`, copies it to a server via SCP, and sets up shared access permissions with `git init --bare --shared` +- **Word Count:** 231 + +## 3. Setting Up the Server +- **File:** `book/04-git-server/sections/setting-up-server.asc` +- **Topic:** SSH-based Git server access using the authorized_keys method +- **Scenario:** Administrator creates a `git` user, sets up `.ssh` directory with proper permissions, adds developer public keys to `authorized_keys`, creates a bare repository, demonstrates developer push/clone workflows, and restricts shell access using `git-shell` +- **Word Count:** 855 + +## 4. Git Daemon +- **File:** `book/04-git-server/sections/git-daemon.asc` +- **Topic:** Serving repositories over the git:// protocol with unauthenticated access +- **Scenario:** Reader starts the git daemon with specific options, configures it using systemd on Linux, and marks repositories as exportable with the `git-daemon-export-ok` file +- **Word Count:** 457 + +## 5. GitWeb — Permanent Installation +- **File:** `book/04-git-server/sections/gitweb.asc` +- **Topic:** Building and deploying GitWeb CGI script for web-based repository viewing +- **Scenario:** Reader clones Git source, builds the GitWeb CGI script specifying the project root, copies it to a web server directory, and configures an Apache VirtualHost with CGI handler +- **Word Count:** 252 + +## 6. Smart HTTP +- **File:** `book/04-git-server/sections/smart-http.asc` +- **Topic:** Setting up Smart HTTP protocol with Apache for authenticated and unauthenticated access +- **Scenario:** Reader installs Apache with required modules, changes directory ownership to www-data, configures Apache with `git-http-backend` directives, creates `.htpasswd` authentication file, and sets up auth blocks +- **Word Count:** 312 diff --git a/00-notes/05-distributed-git/walkthroughs.md b/00-notes/05-distributed-git/walkthroughs.md new file mode 100644 index 000000000..409718a50 --- /dev/null +++ b/00-notes/05-distributed-git/walkthroughs.md @@ -0,0 +1,73 @@ +# Chapter 5: Distributed Git — Walkthroughs + +## 1. Private Small Team +- **File:** `book/05-distributed-git/sections/contributing.asc` +- **Topic:** Two-developer collaboration workflow on a shared repository +- **Scenario:** John and Jessica clone a shared repo, make changes, push, handle rejected pushes, fetch updates, merge, and push again through a full integration cycle +- **Word Count:** 2,159 + +## 2. Private Managed Team +- **File:** `book/05-distributed-git/sections/contributing.asc` +- **Topic:** Multi-developer workflow with parallel feature branches and an integration manager +- **Scenario:** Jessica works on two parallel features — featureA with John and featureB with Josie — creating branches, pushing, fetching, merging remote branches, and handling upstream configuration +- **Word Count:** 1,663 + +## 3. Forked Public Project +- **File:** `book/05-distributed-git/sections/contributing.asc` +- **Topic:** Contributing to a public project through forking +- **Scenario:** Reader clones the main repo, creates topic branches, forks the project, adds the fork as a remote, pushes, creates pull requests, rebases when needed, and handles multiple feature submissions +- **Word Count:** 2,129 + +## 4. Public Project over Email +- **File:** `book/05-distributed-git/sections/contributing.asc` +- **Topic:** Email-based patch contribution workflow +- **Scenario:** Reader creates topic branches, uses `git format-patch` to generate patch files, configures Git IMAP/SMTP settings in `~/.gitconfig`, and sends patches via `git imap-send` or `git send-email` +- **Word Count:** 1,651 + +## 5. Applying Patches with git apply +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Applying email patches using `git apply` +- **Scenario:** Maintainer applies patches received via email, checks patches before applying, understands differences from the `patch` command, and handles the manual staging/commit process +- **Word Count:** 471 + +## 6. Applying Patches with git am +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Applying format-patch generated patches with `git am` +- **Scenario:** Maintainer uses `git am` for clean applies, resolves conflicts with manual editing, uses the `-3` option for three-way merges, and handles interactive mode for multiple patches +- **Word Count:** 1,068 + +## 7. Checking Out Remote Branches +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Fetching and reviewing contributor branches +- **Scenario:** Maintainer adds a contributor's repository as a remote, fetches from it, and checks out remote branches to test contributed work, including one-time pulls without permanent remotes +- **Word Count:** 432 + +## 8. Determining What Is Introduced +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Reviewing contributed changes with diff and log analysis +- **Scenario:** Maintainer uses `git log`, `git diff`, and `git merge-base` with triple-dot syntax to understand what changes a topic branch will introduce when merged +- **Word Count:** 533 + +## 9. Tagging Your Releases +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Creating signed tags and distributing PGP keys +- **Scenario:** Maintainer creates signed tags for releases, distributes their PGP public key in the repository as a blob, and enables others to verify signed tags by importing keys +- **Word Count:** 393 + +## 10. Generating a Build Number +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Creating human-readable version identifiers with `git describe` +- **Scenario:** Maintainer uses `git describe` to generate version strings for builds, understanding the output format and its use in archiving +- **Word Count:** 279 + +## 11. Preparing a Release +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Creating distributable release archives +- **Scenario:** Maintainer uses `git archive` to generate tarball and zip formats with proper directory structure for distribution +- **Word Count:** 237 + +## 12. The Shortlog +- **File:** `book/05-distributed-git/sections/maintaining.asc` +- **Topic:** Generating a summary of commits for release announcements +- **Scenario:** Maintainer uses `git shortlog` to produce an author-grouped commit summary since the last release, suitable for mailing list announcements +- **Word Count:** 220 diff --git a/00-notes/06-github/walkthroughs.md b/00-notes/06-github/walkthroughs.md new file mode 100644 index 000000000..66e2d7537 --- /dev/null +++ b/00-notes/06-github/walkthroughs.md @@ -0,0 +1,55 @@ +# Chapter 6: GitHub — Walkthroughs + +## 1. SSH Access Configuration +- **File:** `book/06-github/sections/1-setting-up-account.asc` +- **Topic:** Adding SSH keys to a GitHub account +- **Scenario:** Reader navigates to GitHub account settings, opens the SSH keys section, and pastes their public key to enable SSH-based authentication +- **Word Count:** 181 + +## 2. Avatar Upload and Configuration +- **File:** `book/06-github/sections/1-setting-up-account.asc` +- **Topic:** Replacing the default GitHub avatar +- **Scenario:** Reader navigates to the Profile tab, uploads a custom image, and crops it for their profile picture +- **Word Count:** 128 + +## 3. Creating a Pull Request +- **File:** `book/06-github/sections/2-contributing.asc` +- **Topic:** Full fork-and-PR contribution workflow +- **Scenario:** Reader forks the Arduino "blink" project, clones it locally, creates a topic branch, modifies LED delay timing in the code, commits, pushes to their fork, and opens a Pull Request on GitHub +- **Word Count:** 715 + +## 4. Iterating on a Pull Request +- **File:** `book/06-github/sections/2-contributing.asc` +- **Topic:** Responding to reviewer feedback on a Pull Request +- **Scenario:** Reader receives review comments, makes additional commits to the topic branch, pushes updates, and observes the collaborative review cycle through GitHub's UI +- **Word Count:** 279 + +## 5. Keeping up with Upstream +- **File:** `book/06-github/sections/2-contributing.asc` +- **Topic:** Resolving merge conflicts in a Pull Request +- **Scenario:** Reader adds the original repository as a remote, fetches upstream changes, merges the upstream master branch, resolves conflicts, and pushes the updated branch +- **Word Count:** 392 + +## 6. Setting up and Testing GitHub Webhooks +- **File:** `book/06-github/sections/5-scripting.asc` +- **Topic:** Configuring webhooks with a Ruby Sinatra service +- **Scenario:** Reader builds a webhook handler that checks commit metadata (pusher, branch, files) and sends email notifications, then configures and tests the webhook through GitHub's settings +- **Word Count:** 366 + +## 7. Making API Calls to Comment on Issues +- **File:** `book/06-github/sections/5-scripting.asc` +- **Topic:** Authenticating and posting comments via the GitHub API +- **Scenario:** Reader generates a personal access token, constructs an authenticated `curl` POST request, and posts a comment on a GitHub issue +- **Word Count:** 272 + +## 8. Changing Pull Request Status via API +- **File:** `book/06-github/sections/5-scripting.asc` +- **Topic:** Automated commit validation using webhooks and the Status API +- **Scenario:** Reader builds a Ruby Sinatra webhook handler that checks commit messages for "Signed-off-by", parses webhook payloads, and posts commit status updates back to GitHub +- **Word Count:** 409 + +## 9. Keeping a GitHub Fork Up-to-Date +- **File:** `book/06-github/sections/2-contributing.asc` +- **Topic:** Syncing a forked repository with the original upstream +- **Scenario:** Reader syncs their fork using two approaches: a simple one-time `git pull` with a URL, and a more automated configuration using `git remote` setup +- **Word Count:** 359 diff --git a/00-notes/07-git-tools/walkthroughs.md b/00-notes/07-git-tools/walkthroughs.md new file mode 100644 index 000000000..076b7b6a2 --- /dev/null +++ b/00-notes/07-git-tools/walkthroughs.md @@ -0,0 +1,229 @@ +# Chapter 7: Git Tools — Walkthroughs + +## 1. Merge Conflicts +- **File:** `book/07-git-tools/sections/advanced-merging.asc` +- **Topic:** Resolving a merge conflict end-to-end +- **Scenario:** Two branches modify a Ruby `hello.rb` file (one changes line endings and text, another adds documentation); when merged, conflicts arise and are resolved using various Git tools +- **Word Count:** 1,471 + +## 2. Aborting a Merge +- **File:** `book/07-git-tools/sections/advanced-merging.asc` +- **Topic:** Escaping a merge conflict state +- **Scenario:** Reader uses `git merge --abort` and `git reset --hard HEAD` to abandon an in-progress merge +- **Word Count:** 207 + +## 3. Ignoring Whitespace +- **File:** `book/07-git-tools/sections/advanced-merging.asc` +- **Topic:** Resolving whitespace-related merge conflicts +- **Scenario:** Reader re-merges using `-Xignore-space-change` to bypass whitespace differences +- **Word Count:** 284 + +## 4. Manual File Re-merging +- **File:** `book/07-git-tools/sections/advanced-merging.asc` +- **Topic:** Manually resolving conflicts using low-level Git commands +- **Scenario:** Reader extracts conflicted file versions with `git show :1:/:2:/:3:`, processes them through `dos2unix`, and uses `git merge-file` to resolve conflicts +- **Word Count:** 531 + +## 5. Checking Out Conflicts +- **File:** `book/07-git-tools/sections/advanced-merging.asc` +- **Topic:** Viewing conflict markers with additional context +- **Scenario:** Reader uses `git checkout --conflict=diff3` for three-way conflict markers and diff comparison commands to understand merge changes +- **Word Count:** 718 + +## 6. Undoing Merges — Fix the References +- **File:** `book/07-git-tools/sections/advanced-merging.asc` +- **Topic:** Undoing an accidental merge by moving branch pointers +- **Scenario:** Reader uses `git reset --hard HEAD~` to undo an accidental merge by resetting the branch to its pre-merge state +- **Word Count:** 306 + +## 7. Undoing Merges — Reverse the Commit +- **File:** `book/07-git-tools/sections/advanced-merging.asc` +- **Topic:** Reverting a merge commit +- **Scenario:** Reader uses `git revert -m 1 HEAD` to create a new commit that undoes a merge, then navigates the complexity of re-merging after a revert +- **Word Count:** 409 + +## 8. Bundling +- **File:** `book/07-git-tools/sections/bundling.asc` +- **Topic:** Creating and using Git bundle files for offline transfer +- **Scenario:** Reader creates a bundle from a repository, sends it to another person, then clones and pulls updates from the bundle file +- **Word Count:** 1,127 + +## 9. File Annotation with Git Blame +- **File:** `book/07-git-tools/sections/debugging.asc` +- **Topic:** Identifying which commits modified specific lines +- **Scenario:** Reader uses `git blame -L 69,82 Makefile` to annotate lines and `-C` to track code movement across files +- **Word Count:** 407 + +## 10. Binary Search with Git Bisect +- **File:** `book/07-git-tools/sections/debugging.asc` +- **Topic:** Finding the commit that introduced a bug via binary search +- **Scenario:** Reader uses `git bisect` with manual good/bad testing steps, then automates bisect with a test script +- **Word Count:** 788 + +## 11. Staging and Unstaging Files (Interactive) +- **File:** `book/07-git-tools/sections/interactive-staging.asc` +- **Topic:** Selectively staging files using interactive mode +- **Scenario:** Reader uses `git add -i` to interactively stage and unstage files using the revert option +- **Word Count:** 479 + +## 12. Staging Patches +- **File:** `book/07-git-tools/sections/interactive-staging.asc` +- **Topic:** Partially staging a file using patch mode +- **Scenario:** Reader uses `git add -p` to respond to hunks interactively, staging only selected portions of a file +- **Word Count:** 328 + +## 13. Replace — Repository Splitting +- **File:** `book/07-git-tools/sections/replace.asc` +- **Topic:** Splitting and reconnecting repository history with `git replace` +- **Scenario:** Reader splits a repository history into two, creates a base commit with instructions, rebases history, and uses `git replace` to recombine the histories seamlessly +- **Word Count:** 2,118 + +## 14. Rerere — Merge Conflict Resolution Memory +- **File:** `book/07-git-tools/sections/rerere.asc` +- **Topic:** Recording and replaying merge conflict resolutions +- **Scenario:** Reader enables rerere, creates merge conflicts, records resolutions, and has Git automatically reapply those resolutions during a rebase +- **Word Count:** 1,849 + +## 15. Reset — The Three Trees Workflow +- **File:** `book/07-git-tools/sections/reset.asc` +- **Topic:** Understanding Git's three-tree model through the commit lifecycle +- **Scenario:** Reader walks through `git init`/`git add`/`git commit`/edit cycles, observing how HEAD, Index, and Working Directory change at each step via diagrams +- **Word Count:** 1,246 + +## 16. Squashing Commits with Reset +- **File:** `book/07-git-tools/sections/reset.asc` +- **Topic:** Squashing multiple commits into one using `git reset --soft` +- **Scenario:** Reader uses `git reset --soft HEAD~2` combined with `git commit` to collapse multiple commits into a single commit +- **Word Count:** 289 + +## 17. Changing Multiple Commit Messages +- **File:** `book/07-git-tools/sections/rewriting-history.asc` +- **Topic:** Editing commit messages with interactive rebase +- **Scenario:** Reader uses `git rebase -i HEAD~3`, changes `pick` to `edit`, and walks through the amend/continue cycle for each commit +- **Word Count:** 1,020 + +## 18. Squashing Commits (Interactive Rebase) +- **File:** `book/07-git-tools/sections/rewriting-history.asc` +- **Topic:** Combining commits into one using interactive rebase +- **Scenario:** Reader changes `pick` to `squash` in the rebase script, then edits the merged commit message +- **Word Count:** 432 + +## 19. Splitting a Commit +- **File:** `book/07-git-tools/sections/rewriting-history.asc` +- **Topic:** Breaking a single commit into multiple commits +- **Scenario:** Reader uses `edit` in interactive rebase, then `git reset HEAD^` to unstage, followed by multiple `git commit` commands to create separate commits +- **Word Count:** 460 + +## 20. Removing a File from Every Commit +- **File:** `book/07-git-tools/sections/rewriting-history.asc` +- **Topic:** Rewriting history to remove a file from all commits +- **Scenario:** Reader uses `git filter-branch --tree-filter` to remove a file across the entire commit history +- **Word Count:** 234 + +## 21. Git Grep +- **File:** `book/07-git-tools/sections/searching.asc` +- **Topic:** Searching code with Git's built-in grep +- **Scenario:** Reader searches through committed trees using `git grep` with flags (`-n`, `-c`, `-p`, `--and`) to locate patterns in source code +- **Word Count:** 460 + +## 22. Line Log Search +- **File:** `book/07-git-tools/sections/searching.asc` +- **Topic:** Tracking the history of a specific function +- **Scenario:** Reader uses `git log -L :function:file` to view how a specific function changed across commits +- **Word Count:** 294 + +## 23. Signing Tags +- **File:** `book/07-git-tools/sections/signing.asc` +- **Topic:** Creating GPG-signed tags +- **Scenario:** Reader signs a tag with `git tag -s` and views the GPG signature with `git show` +- **Word Count:** 244 + +## 24. Verifying Tags +- **File:** `book/07-git-tools/sections/signing.asc` +- **Topic:** Verifying GPG signatures on tags +- **Scenario:** Reader uses `git tag -v` to verify signed tags, with both success and failure cases shown +- **Word Count:** 234 + +## 25. Signing Commits +- **File:** `book/07-git-tools/sections/signing.asc` +- **Topic:** Creating and verifying GPG-signed commits +- **Scenario:** Reader signs commits with `git commit -S`, verifies signatures with `git log --show-signature` and `%G?` format, and uses `--verify-signatures` for merge/pull +- **Word Count:** 445 + +## 26. Stashing Your Work +- **File:** `book/07-git-tools/sections/stashing-cleaning.asc` +- **Topic:** Saving and restoring in-progress work with git stash +- **Scenario:** Reader saves work with `git stash`, lists stashes, and reapplies them with `--index` to restore staged status +- **Word Count:** 678 + +## 27. Creative Stashing +- **File:** `book/07-git-tools/sections/stashing-cleaning.asc` +- **Topic:** Advanced stash options +- **Scenario:** Reader uses `--keep-index`, `--include-untracked/-u`, and `--patch` for selective stashing of different file categories +- **Word Count:** 435 + +## 28. Creating a Branch from a Stash +- **File:** `book/07-git-tools/sections/stashing-cleaning.asc` +- **Topic:** Applying stashed changes to a new branch +- **Scenario:** Reader uses `git stash branch` to create a new branch with stashed changes cleanly applied +- **Word Count:** 187 + +## 29. Cleaning Your Working Directory +- **File:** `book/07-git-tools/sections/stashing-cleaning.asc` +- **Topic:** Removing untracked files from the working directory +- **Scenario:** Reader uses `git clean` with various flags (`-f -d`, `-n`, `-x`, `-i`) to safely remove untracked files, with a safety warning about data loss +- **Word Count:** 407 + +## 30. Starting with Submodules +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Adding a submodule to a project +- **Scenario:** Reader adds a submodule with `git submodule add`, examines `.gitmodules`, and commits the changes +- **Word Count:** 626 + +## 31. Cloning a Project with Submodules +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Cloning and initializing a project that contains submodules +- **Scenario:** Reader clones a project, initializes submodules with `git submodule init/update`, and uses `--recurse-submodules` as a shortcut +- **Word Count:** 744 + +## 32. Pulling in Upstream Changes from the Submodule Remote +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Updating submodules to the latest upstream version +- **Scenario:** Reader fetches and merges submodule updates, uses `git submodule update --remote`, and configures which branch to track +- **Word Count:** 921 + +## 33. Pulling Upstream Changes from the Project Remote +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Syncing superproject changes that update submodule references +- **Scenario:** Reader pulls superproject changes and synchronizes submodules with `git submodule update --init --recursive` and `git submodule sync` +- **Word Count:** 703 + +## 34. Working on a Submodule +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Making changes inside submodules +- **Scenario:** Reader checks out branches in submodules and uses `--merge` and `--rebase` options with `git submodule update --remote` for local changes +- **Word Count:** 1,122 + +## 35. Publishing Submodule Changes +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Pushing submodule changes before the superproject +- **Scenario:** Reader uses `git push --recurse-submodules=check` and `=on-demand` to ensure submodule changes are pushed before the superproject +- **Word Count:** 544 + +## 36. Merging Submodule Changes +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Resolving submodule merge conflicts +- **Scenario:** Reader examines divergent submodule commit SHA-1s, creates branches, and merges submodule changes manually to resolve conflicts +- **Word Count:** 893 + +## 37. Submodule Foreach +- **File:** `book/07-git-tools/sections/submodules.asc` +- **Topic:** Running commands across all submodules +- **Scenario:** Reader uses `git submodule foreach` to stash, create branches, and view diffs across all submodules at once +- **Word Count:** 521 + +## 38. Subtree Merging +- **File:** `book/07-git-tools/sections/subtree-merges.asc` +- **Topic:** Adding a separate project as a subdirectory using subtree merge +- **Scenario:** Reader adds a project via `git read-tree`, pulls upstream changes, and merges them back using the subtree merge strategy +- **Word Count:** 745 diff --git a/00-notes/08-customizing-git/walkthroughs.md b/00-notes/08-customizing-git/walkthroughs.md new file mode 100644 index 000000000..7e28b7197 --- /dev/null +++ b/00-notes/08-customizing-git/walkthroughs.md @@ -0,0 +1,67 @@ +# Chapter 8: Customizing Git — Walkthroughs + +## 1. Setting Up External Merge and Diff Tools with P4Merge +- **File:** `book/08-customizing-git/sections/config.asc` +- **Topic:** Configuring a visual merge/diff tool +- **Scenario:** Reader downloads P4Merge, creates wrapper scripts (`extMerge` and `extDiff`), makes them executable, configures Git to use them via `git config`, tests with `git diff`, and switches to KDiff3 as an alternative +- **Word Count:** 1,348 + +## 2. Diffing Word Documents Using Git Attributes +- **File:** `book/08-customizing-git/sections/attributes.asc` +- **Topic:** Converting binary Word documents to diffable text +- **Scenario:** Reader installs and configures `docx2txt`, creates a wrapper script, configures Git with `git config`, and demonstrates the actual diff output showing changes in a Word document +- **Word Count:** 1,166 + +## 3. Extracting EXIF Data from Images for Diffing +- **File:** `book/08-customizing-git/sections/attributes.asc` +- **Topic:** Diffing image files by extracting EXIF metadata +- **Scenario:** Reader installs `exiftool`, configures it in `.gitattributes` for `.png` files, replaces an image, and runs `git diff` to see textual EXIF metadata changes +- **Word Count:** 542 + +## 4. Implementing C Code Indentation Filter +- **File:** `book/08-customizing-git/sections/attributes.asc` +- **Topic:** Setting up clean/smudge filters for C source files +- **Scenario:** Reader configures `.gitattributes` rules for `*.c` files and sets up `git config` commands to run the `indent` program on commit and `cat` on checkout +- **Word Count:** 287 + +## 5. Setting Up Keyword Expansion with Custom Date Filter +- **File:** `book/08-customizing-git/sections/attributes.asc` +- **Topic:** Custom keyword expansion using clean/smudge filters +- **Scenario:** Reader writes a Ruby script to inject `$Date$` values into files, configures Git filters, creates a test file, commits, and verifies the date substitution on checkout +- **Word Count:** 762 + +## 6. Enforcing Commit Message Format via Server-Side Hooks +- **File:** `book/08-customizing-git/sections/policy.asc` +- **Topic:** Server-side update hook for commit message validation +- **Scenario:** Reader builds a Ruby script in the server-side `update` hook that uses `git rev-list` and `git cat-file` to extract commits, tests messages against a `[ref: XXXX]` regex pattern, and rejects non-compliant pushes +- **Word Count:** 1,115 + +## 7. Implementing User-Based ACL System via Hooks +- **File:** `book/08-customizing-git/sections/policy.asc` +- **Topic:** Path-based access control enforcement with server-side hooks +- **Scenario:** Reader creates an ACL file format, writes a Ruby method to parse ACL rules, uses `git rev-list` and `git log` to identify modified files, and checks user permissions against the ACL +- **Word Count:** 1,496 + +## 8. Testing the Server-Side Enforcement Policies +- **File:** `book/08-customizing-git/sections/policy.asc` +- **Topic:** Verifying server-side hook behavior +- **Scenario:** Reader runs `git push` with a non-compliant commit message to see hook rejection output, then tests a documentation writer attempting to modify files outside their ACL scope +- **Word Count:** 744 + +## 9. Setting Up Client-Side Commit Message Validation +- **File:** `book/08-customizing-git/sections/policy.asc` +- **Topic:** Client-side `commit-msg` hook for pre-push validation +- **Scenario:** Reader creates a Ruby `commit-msg` hook script that validates messages against the regex pattern, demonstrates both failed and successful commits +- **Word Count:** 558 + +## 10. Setting Up Client-Side ACL Permission Checking +- **File:** `book/08-customizing-git/sections/policy.asc` +- **Topic:** Client-side `pre-commit` hook for ACL enforcement +- **Scenario:** Reader creates a `pre-commit` hook that reads the ACL file, uses `git diff-index` to get staged changes, checks permissions, and exits non-zero if the user lacks access +- **Word Count:** 1,101 + +## 11. Setting Up Pre-Rebase Hook to Prevent Pushing Rebased Commits +- **File:** `book/08-customizing-git/sections/policy.asc` +- **Topic:** Pre-rebase hook to protect already-pushed commits +- **Scenario:** Reader creates a `pre-rebase` script using `git rev-list` and `git branch -r` to identify commits already pushed to remote branches, aborting the rebase if any match +- **Word Count:** 688 diff --git a/00-notes/09-git-and-other-scms/walkthroughs.md b/00-notes/09-git-and-other-scms/walkthroughs.md new file mode 100644 index 000000000..dcceb602a --- /dev/null +++ b/00-notes/09-git-and-other-scms/walkthroughs.md @@ -0,0 +1,133 @@ +# Chapter 9: Git and Other Systems — Walkthroughs + +## 1. Git-Mercurial Bridge — Installing git-remote-hg +- **File:** `book/09-git-and-other-scms/sections/client-hg.asc` +- **Topic:** Setting up the git-remote-hg bridge tool +- **Scenario:** Reader downloads the script, installs Python dependencies, and clones a Mercurial test repository +- **Word Count:** 142 + +## 2. Git-Mercurial Bridge — Getting Started +- **File:** `book/09-git-and-other-scms/sections/client-hg.asc` +- **Topic:** Exploring a cloned Mercurial repository from Git +- **Scenario:** Reader clones a Mercurial repository using Git, examines the resulting structure, explores git refs and notes mapping, and sets up `.gitignore` compatibility +- **Word Count:** 557 + +## 3. Git-Mercurial Bridge — Workflow +- **File:** `book/09-git-and-other-scms/sections/client-hg.asc` +- **Topic:** Full round-trip workflow between Git and Mercurial +- **Scenario:** Reader makes local commits, fetches from remote, merges changes, pushes back to Mercurial, and verifies changes on the Mercurial side +- **Word Count:** 476 + +## 4. Git-Mercurial Bridge — Branches and Bookmarks +- **File:** `book/09-git-and-other-scms/sections/client-hg.asc` +- **Topic:** Working with Mercurial bookmarks and branches from Git +- **Scenario:** Reader creates feature branches, pushes branches, handles permanent branches, and learns the differences between Git and Mercurial branching models +- **Word Count:** 782 + +## 5. Git Fusion — Setting Up +- **File:** `book/09-git-and-other-scms/sections/client-p4.asc` +- **Topic:** Setting up the Git Fusion virtual machine for Perforce +- **Scenario:** Reader imports the VM, customizes user passwords, creates a Perforce user, configures SSL verification, and tests the connection +- **Word Count:** 326 + +## 6. Git Fusion — Configuration +- **File:** `book/09-git-and-other-scms/sections/client-p4.asc` +- **Topic:** Understanding Git Fusion configuration files +- **Scenario:** Reader explores global and repository-specific configs, examines branch/view mappings, and reviews user mapping files for Git-Perforce interoperability +- **Word Count:** 660 + +## 7. Git Fusion — Workflow +- **File:** `book/09-git-and-other-scms/sections/client-p4.asc` +- **Topic:** Complete Git Fusion workflow between Git and Perforce +- **Scenario:** Reader clones a repository, makes commits, fetches changes from Perforce, merges conflicts, pushes back, and examines results in Perforce's revision graph +- **Word Count:** 1,009 + +## 8. Git-p4 — Setting Up +- **File:** `book/09-git-and-other-scms/sections/client-p4.asc` +- **Topic:** Configuring environment variables for git-p4 +- **Scenario:** Reader configures `P4PORT` and `P4USER` environment variables to connect to a Perforce server +- **Word Count:** 65 + +## 9. Git-p4 — Getting Started +- **File:** `book/09-git-and-other-scms/sections/client-p4.asc` +- **Topic:** Performing a shallow clone of a Perforce depot +- **Scenario:** Reader uses `git p4 clone` to import a depot, examines the resulting repository structure, and understands git-p4's remote refs +- **Word Count:** 208 + +## 10. Git-p4 — Workflow +- **File:** `book/09-git-and-other-scms/sections/client-p4.asc` +- **Topic:** Complete git-p4 workflow with Perforce +- **Scenario:** Reader makes commits, syncs with the Perforce server, rebases work, submits changes via interactive editor, and handles merge commits +- **Word Count:** 1,317 + +## 11. Git-p4 — Branching +- **File:** `book/09-git-and-other-scms/sections/client-p4.asc` +- **Topic:** Working with multiple Perforce branches in Git +- **Scenario:** Reader detects branches with `--detect-branches`, configures branch mappings, and syncs/submits to multiple branches +- **Word Count:** 445 + +## 12. Git-SVN — Setting Up +- **File:** `book/09-git-and-other-scms/sections/client-svn.asc` +- **Topic:** Creating a local Subversion repository for testing +- **Scenario:** Reader creates a local SVN repo, enables revprop changes, and syncs content from a remote SVN server using `svnsync` +- **Word Count:** 111 + +## 13. Git-SVN — Getting Started +- **File:** `book/09-git-and-other-scms/sections/client-svn.asc` +- **Topic:** Importing a Subversion repository with `git svn clone` +- **Scenario:** Reader clones with `--stdlayout` for trunk/branches/tags layout and examines the resulting Git repository structure and remote refs +- **Word Count:** 409 + +## 14. Git-SVN — Committing Back to Subversion +- **File:** `book/09-git-and-other-scms/sections/client-svn.asc` +- **Topic:** Pushing Git commits back to a Subversion server +- **Scenario:** Reader makes local Git commits and pushes back to SVN using `git svn dcommit`, observing how SVN commit IDs are embedded in commit messages +- **Word Count:** 325 + +## 15. Git-SVN — Pulling in New Changes +- **File:** `book/09-git-and-other-scms/sections/client-svn.asc` +- **Topic:** Syncing when the SVN repository has diverged +- **Scenario:** Reader handles conflicts when SVN diverges from local Git work, using `git svn rebase` to sync and rebase local commits +- **Word Count:** 654 + +## 16. Git-SVN — Creating a New SVN Branch +- **File:** `book/09-git-and-other-scms/sections/client-svn.asc` +- **Topic:** Creating branches in Subversion from Git +- **Scenario:** Reader uses `git svn branch` to create a new branch on the SVN server, understanding the server-side operations +- **Word Count:** 106 + +## 17. Git-SVN — Switching Active Branches +- **File:** `book/09-git-and-other-scms/sections/client-svn.asc` +- **Topic:** Tracking and switching between Subversion branches in Git +- **Scenario:** Reader sets up local Git branches to track SVN branches, merges branches while understanding SVN's linear history model limitations +- **Word Count:** 350 + +## 18. A Custom Importer +- **File:** `book/09-git-and-other-scms/sections/import-custom.asc` +- **Topic:** Building a custom import script using `git fast-import` +- **Scenario:** Reader writes a complete Ruby script that reads a custom source directory structure, generates marks, converts dates, handles files, and pipes everything through `git fast-import` to create a Git repository +- **Word Count:** 1,694 + +## 19. Importing from Mercurial +- **File:** `book/09-git-and-other-scms/sections/import-hg.asc` +- **Topic:** Converting a Mercurial repository to Git +- **Scenario:** Reader clones the source repo, creates author mapping files, runs the `hg-fast-export` tool, and verifies the import +- **Word Count:** 760 + +## 20. Importing from Perforce (Git Fusion) +- **File:** `book/09-git-and-other-scms/sections/import-p4.asc` +- **Topic:** Using Git Fusion for a one-time Perforce-to-Git migration +- **Scenario:** Reader configures project settings and user mappings to produce a native Git repository ready to push to a Git host +- **Word Count:** 70 + +## 21. Importing from Perforce (Git-p4) +- **File:** `book/09-git-and-other-scms/sections/import-p4.asc` +- **Topic:** Using `git p4 clone` for a one-time Perforce import +- **Scenario:** Reader imports a Perforce project with `git p4 clone` and uses `git filter-branch` to clean up git-p4 metadata from commit messages +- **Word Count:** 460 + +## 22. Importing from Subversion +- **File:** `book/09-git-and-other-scms/sections/import-svn.asc` +- **Topic:** Complete SVN-to-Git conversion with post-import cleanup +- **Scenario:** Reader creates author mapping files, uses `git svn clone` with various flags, performs post-import cleanup of branches/tags/refs, and pushes to a new Git server +- **Word Count:** 938 diff --git a/00-notes/10-git-internals/walkthroughs.md b/00-notes/10-git-internals/walkthroughs.md new file mode 100644 index 000000000..a1f4f81e5 --- /dev/null +++ b/00-notes/10-git-internals/walkthroughs.md @@ -0,0 +1,103 @@ +# Chapter 10: Git Internals — Walkthroughs + +## 1. Data Recovery via Reflog +- **File:** `book/10-git-internals/sections/maintenance.asc` +- **Topic:** Recovering lost commits using the reflog +- **Scenario:** Reader uses `git reset --hard` to move master to an older commit, then recovers the lost commits using `git reflog` and `git branch` to re-establish access +- **Word Count:** 445 + +## 2. Data Recovery via git fsck +- **File:** `book/10-git-internals/sections/maintenance.asc` +- **Topic:** Finding dangling commits when the reflog is unavailable +- **Scenario:** Reader deletes the reflog, then uses `git fsck --full` to locate dangling commits and recovers a lost commit via `git branch` +- **Word Count:** 186 + +## 3. Removing Large Objects from History +- **File:** `book/10-git-internals/sections/maintenance.asc` +- **Topic:** Purging accidentally committed large files from repository history +- **Scenario:** Reader adds a large tarball accidentally, removes it, discovers it still takes space, uses `git verify-pack` and `git rev-list` to locate the object, then uses `git filter-branch` to rewrite history, followed by `git gc` and `git prune` +- **Word Count:** 958 + +## 4. Creating and Manipulating Git Objects +- **File:** `book/10-git-internals/sections/objects.asc` +- **Topic:** Understanding Git's content-addressable filesystem via plumbing commands +- **Scenario:** Reader initializes a repo, uses `git hash-object` to store content, `git cat-file` to retrieve it, and stores multiple file versions to understand how blobs work +- **Word Count:** 622 + +## 5. Creating Tree Objects +- **File:** `book/10-git-internals/sections/objects.asc` +- **Topic:** Manually creating tree objects with low-level commands +- **Scenario:** Reader uses `git update-index`, `git write-tree`, and `git read-tree` to create staging areas, write tree snapshots, and combine trees into nested structures +- **Word Count:** 505 + +## 6. Creating Commit Objects +- **File:** `book/10-git-internals/sections/objects.asc` +- **Topic:** Manually creating commit objects +- **Scenario:** Reader creates three sequential commits by hand using `git commit-tree`, examines their structure with `git cat-file`, and views the resulting history with `git log` +- **Word Count:** 272 + +## 7. Object Storage via Ruby +- **File:** `book/10-git-internals/sections/objects.asc` +- **Topic:** Understanding Git's object storage format +- **Scenario:** Reader uses Ruby code to manually construct a header, calculate SHA-1, compress with zlib, write an object to disk, and verify with `git cat-file` +- **Word Count:** 428 + +## 8. Demonstrating Packfiles +- **File:** `book/10-git-internals/sections/packfiles.asc` +- **Topic:** Understanding Git's packfile and delta compression mechanism +- **Scenario:** Reader adds a large file and modifies it, runs `git gc` to trigger packing, then uses `git cat-file` and `git verify-pack` to examine delta compression +- **Word Count:** 583 + +## 9. Creating References Manually +- **File:** `book/10-git-internals/sections/refs.asc` +- **Topic:** Understanding Git references by creating them manually +- **Scenario:** Reader writes a SHA-1 directly to `.git/refs/heads/master`, then uses the safer `git update-ref` to create branches +- **Word Count:** 225 + +## 10. Working with HEAD and Symbolic References +- **File:** `book/10-git-internals/sections/refs.asc` +- **Topic:** Understanding the HEAD file and symbolic-ref mechanism +- **Scenario:** Reader inspects the HEAD file directly, uses `git checkout` and `git symbolic-ref` to manipulate and understand how HEAD tracks the current branch +- **Word Count:** 198 + +## 11. Creating Annotated Tags (Internals) +- **File:** `book/10-git-internals/sections/refs.asc` +- **Topic:** Understanding tag objects at the internals level +- **Scenario:** Reader creates lightweight tags with `git update-ref` and annotated tags with `git tag -a`, then inspects the tag object structure with `git cat-file` +- **Word Count:** 246 + +## 12. Working with Remote References +- **File:** `book/10-git-internals/sections/refs.asc` +- **Topic:** Understanding how Git stores remote-tracking references +- **Scenario:** Reader adds a remote, pushes commits, then inspects the stored reference in `.git/refs/remotes/origin/master` +- **Word Count:** 149 + +## 13. The Dumb Protocol +- **File:** `book/10-git-internals/sections/transfer-protocols.asc` +- **Topic:** Understanding the HTTP dumb protocol for fetching +- **Scenario:** Reader simulates the HTTP fetch process step by step: fetching `info/refs`, checking HEAD, fetching individual commit objects, discovering packfiles, downloading pack indexes, and extracting objects +- **Word Count:** 587 + +## 14. The Smart Protocol — SSH Upload +- **File:** `book/10-git-internals/sections/transfer-protocols.asc` +- **Topic:** Understanding the SSH handshake for pushing data +- **Scenario:** Reader observes how `git push` initiates `send-pack`, the server responds with references and capabilities, and the client transmits the packfile +- **Word Count:** 342 + +## 15. The Smart Protocol — HTTP(S) Upload +- **File:** `book/10-git-internals/sections/transfer-protocols.asc` +- **Topic:** Understanding the HTTP variant for pushing data +- **Scenario:** Reader observes the HTTP handshake (GET for initial info, POST for packfile) and how it differs from SSH +- **Word Count:** 189 + +## 16. The Smart Protocol — SSH Download +- **File:** `book/10-git-internals/sections/transfer-protocols.asc` +- **Topic:** Understanding the SSH handshake for fetching data +- **Scenario:** Reader observes how `fetch-pack` connects to `upload-pack`, the server sends references, and the client sends want/have/done commands to initiate packfile transmission +- **Word Count:** 292 + +## 17. The Smart Protocol — HTTP(S) Download +- **File:** `book/10-git-internals/sections/transfer-protocols.asc` +- **Topic:** Understanding the HTTP variant for fetching data +- **Scenario:** Reader observes the two-request pattern: GET for capabilities, POST with want/have commands to fetch the packfile +- **Word Count:** 129 diff --git a/00-notes/A-git-in-other-environments/walkthroughs.md b/00-notes/A-git-in-other-environments/walkthroughs.md new file mode 100644 index 000000000..cad2d150c --- /dev/null +++ b/00-notes/A-git-in-other-environments/walkthroughs.md @@ -0,0 +1,49 @@ +# Appendix A: Git in Other Environments — Walkthroughs + +## 1. Setting Up Git Bash Completion +- **File:** `book/A-git-in-other-environments/sections/bash.asc` +- **Topic:** Enabling Git tab completion in Bash +- **Scenario:** Reader checks their Git version, retrieves the completion file from Git source, copies it to their home directory, adds a source line to `.bashrc`, and tests with `git chec` +- **Word Count:** 133 + +## 2. Customizing Git Bash Prompt +- **File:** `book/A-git-in-other-environments/sections/bash.asc` +- **Topic:** Displaying Git branch and status in the Bash prompt +- **Scenario:** Reader copies `git-prompt.sh` from Git source, adds configuration lines to `.bashrc` with `GIT_PS1_SHOWDIRTYSTATE` and `PS1` exports, and sees branch/status info in their prompt +- **Word Count:** 132 + +## 3. Setting PowerShell ExecutionPolicy +- **File:** `book/A-git-in-other-environments/sections/powershell.asc` +- **Topic:** Configuring PowerShell script execution for posh-git +- **Scenario:** Reader sets the `ExecutionPolicy` to `RemoteSigned`, learning about scopes (LocalMachine vs CurrentUser) and signing requirements +- **Word Count:** 121 + +## 4. Installing posh-git via PowerShell Gallery +- **File:** `book/A-git-in-other-environments/sections/powershell.asc` +- **Topic:** Installing posh-git using the PowerShell package manager +- **Scenario:** Reader runs `Install-Module` commands, handles scope options (CurrentUser vs AllUsers), and resolves potential failures with PowerShellGet and certificates +- **Word Count:** 153 + +## 5. Updating PowerShell Prompt for Git +- **File:** `book/A-git-in-other-environments/sections/powershell.asc` +- **Topic:** Importing posh-git and configuring the prompt +- **Scenario:** Reader executes `Import-Module` and `Add-PoshGitToProfile` to display Git information in their PowerShell prompt on startup +- **Word Count:** 89 + +## 6. Installing posh-git from Source +- **File:** `book/A-git-in-other-environments/sections/powershell.asc` +- **Topic:** Manual posh-git installation from a downloaded release +- **Scenario:** Reader downloads a release, uncompresses it, imports the module using a full file path, and adds it to their profile for automatic loading +- **Word Count:** 73 + +## 7. Setting Up Zsh Git Tab Completion +- **File:** `book/A-git-in-other-environments/sections/zsh.asc` +- **Topic:** Enabling Git tab completion in Zsh +- **Scenario:** Reader adds a single command to `.zshrc` and learns about Zsh's richer completion interface with descriptions and graphical navigation +- **Word Count:** 90 + +## 8. Customizing Zsh Prompt with Git Branch Information +- **File:** `book/A-git-in-other-environments/sections/zsh.asc` +- **Topic:** Displaying Git branch in the Zsh prompt using vcs_info +- **Scenario:** Reader adds `vcs_info` configuration lines to `~/.zshrc`, chooses between right-side (RPROMPT) or left-side (PROMPT) display, and sees the result +- **Word Count:** 144 diff --git a/00-notes/B-embedding-git/walkthroughs.md b/00-notes/B-embedding-git/walkthroughs.md new file mode 100644 index 000000000..17842723e --- /dev/null +++ b/00-notes/B-embedding-git/walkthroughs.md @@ -0,0 +1,25 @@ +# Appendix B: Embedding Git in your Applications — Walkthroughs + +## 1. JGit — Getting Set Up +- **File:** `book/B-embedding-git/sections/jgit.asc` +- **Topic:** Configuring JGit as a dependency in a Java project +- **Scenario:** Reader adds JGit via Maven `pom.xml` dependency, with an alternative path for manually managing binary dependencies and compiling on the command line +- **Word Count:** 130 + +## 2. JGit — Plumbing API +- **File:** `book/B-embedding-git/sections/jgit.asc` +- **Topic:** Using JGit's low-level plumbing API for repository operations +- **Scenario:** Reader creates and opens repositories using `FileRepositoryBuilder`, retrieves references, gets object IDs, performs rev-parse operations, loads raw object contents, creates/deletes branches, and reads configuration values +- **Word Count:** 721 + +## 3. JGit — Porcelain API +- **File:** `book/B-embedding-git/sections/jgit.asc` +- **Topic:** Using JGit's high-level porcelain APIs with fluent builders +- **Scenario:** Reader performs a `git ls-remote`-like operation using the `Git` class, setting up credentials, chaining method calls, and iterating over results +- **Word Count:** 212 + +## 4. Libgit2 — Crafting a Commit (Ruby Bindings) +- **File:** `book/B-embedding-git/sections/libgit2.asc` +- **Topic:** Creating a commit programmatically using Rugged (Libgit2 Ruby bindings) +- **Scenario:** Reader follows 8 sequential steps: writing a blob, populating the index, creating a signature, crafting a commit object with tree/author/committer/message/parents/ref parameters, and looking up the resulting commit +- **Word Count:** 203 diff --git a/00-notes/C-git-commands/walkthroughs.md b/00-notes/C-git-commands/walkthroughs.md new file mode 100644 index 000000000..416a026d7 --- /dev/null +++ b/00-notes/C-git-commands/walkthroughs.md @@ -0,0 +1,3 @@ +# Appendix C: Git Commands — Walkthroughs + +This appendix is a reference listing of Git commands grouped by purpose. It contains no walkthroughs — each command entry is a brief description pointing to where the command is used elsewhere in the book. From ee324e06465a529d2e3df571b0210e2bb71108d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Mar 2026 03:03:38 +0000 Subject: [PATCH 08/18] Add UX designer revision notes for all chapters and appendices Per-chapter analysis of how Pro Git content can be adapted for UX designers, including priority ratings, design tool analogies, content gaps, and structural recommendations. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- .../ux-designer-revision-notes.md | 137 ++++++++++++++++++ .../ux-designer-revision-notes.md | 110 ++++++++++++++ .../ux-designer-revision-notes.md | 121 ++++++++++++++++ .../ux-designer-revision-notes.md | 109 ++++++++++++++ .../ux-designer-revision-notes.md | 100 +++++++++++++ .../06-github/ux-designer-revision-notes.md | 85 +++++++++++ .../ux-designer-revision-notes.md | 131 +++++++++++++++++ .../ux-designer-revision-notes.md | 105 ++++++++++++++ .../ux-designer-revision-notes.md | 92 ++++++++++++ .../ux-designer-revision-notes.md | 110 ++++++++++++++ .../ux-designer-revision-notes.md | 96 ++++++++++++ .../ux-designer-revision-notes.md | 77 ++++++++++ .../ux-designer-revision-notes.md | 85 +++++++++++ 13 files changed, 1358 insertions(+) create mode 100644 00-notes/01-introduction/ux-designer-revision-notes.md create mode 100644 00-notes/02-git-basics/ux-designer-revision-notes.md create mode 100644 00-notes/03-git-branching/ux-designer-revision-notes.md create mode 100644 00-notes/04-git-server/ux-designer-revision-notes.md create mode 100644 00-notes/05-distributed-git/ux-designer-revision-notes.md create mode 100644 00-notes/06-github/ux-designer-revision-notes.md create mode 100644 00-notes/07-git-tools/ux-designer-revision-notes.md create mode 100644 00-notes/08-customizing-git/ux-designer-revision-notes.md create mode 100644 00-notes/09-git-and-other-scms/ux-designer-revision-notes.md create mode 100644 00-notes/10-git-internals/ux-designer-revision-notes.md create mode 100644 00-notes/A-git-in-other-environments/ux-designer-revision-notes.md create mode 100644 00-notes/B-embedding-git/ux-designer-revision-notes.md create mode 100644 00-notes/C-git-commands/ux-designer-revision-notes.md diff --git a/00-notes/01-introduction/ux-designer-revision-notes.md b/00-notes/01-introduction/ux-designer-revision-notes.md new file mode 100644 index 000000000..af905c459 --- /dev/null +++ b/00-notes/01-introduction/ux-designer-revision-notes.md @@ -0,0 +1,137 @@ +# Chapter 1: Getting Started — UX Designer Revision Notes + +## Overview +Chapter 1 introduces version control concepts, Git fundamentals, installation, and first-time setup. For UX designers, the chapter's strongest connection point is the designer mention in "About Version Control" (line 8), but most content uses programmer-centric examples and terminology. + +--- + +## Section: About Version Control (`about-version-control.asc`) + +### Priority: HIGH + +**What Resonates:** +- The concrete pain point of "reverting selected files back to a previous state" maps directly to design iteration +- The mention of keeping "every version of an image or layout" (line 8) validates designers' primary use case + +**What Confuses:** +- The local vs. centralized vs. distributed progression uses only programmer VCS tools (RCS, CVS, Subversion, Perforce) — designers don't know these systems +- "Single point of failure" (line 44) is abstract — needs a concrete design scenario + +**Suggested Analogies:** +- CVCS = Figma's single shared file (everyone connects to one server); DVCS = full local copy plus cloud sync +- Centralized VCS = one master design system file; Distributed VCS = each designer has full history locally + +**Revision Suggestions:** +- After line 8's designer mention, add a concrete scenario: "For example, if you're designing a button component and iterate through five visual treatments, version control lets you go back to any treatment without losing the others." +- In the CVCS section, add: "This is similar to a shared Figma file — if the server is unavailable, no one can work." +- In the DVCS section, add: "With Git, you have the entire project history on your laptop — like having Figma's version history downloaded locally." + +**Gaps:** +- No mention of design-specific workflows (branching for design exploration, merging variations) +- Missing context about binary file support — does Git handle `.sketch`, `.psd`, `.figma` files? + +--- + +## Section: What is Git? (`what-is-git.asc`) + +### Priority: HIGH + +**What Resonates:** +- "Every time you commit... Git takes a picture of what all your files look like" maps to design versioning +- The three states (modified/staged/committed) parallel design workflow: draft → ready for review → approved + +**What Confuses:** +- SHA-1 hash explanation is irrelevant to most designers +- "Stream of snapshots" is jargon — designers think "version history" +- Git directory/working tree/staging area uses file system terminology that doesn't map to design tools + +**Suggested Analogies:** +- Snapshots = Figma version history entries +- Staging area = selecting which components/artboards to include in this release +- Modified/Staged/Committed = tweaked but unsaved / marked ready for this update / officially part of design system v2.1 + +**Revision Suggestions:** +- Add after snapshot explanation: "In design terms, each commit is a snapshot of all your designs at a specific moment — identical to Figma's version history." +- Simplify SHA-1 section to: "Every commit is identified uniquely and permanently. You don't need to understand the technical detail." +- Rework three states with design workflow example + +**Gaps:** +- Binary file handling not mentioned — crucial for designers +- No preview of collaboration workflow (push/pull) + +--- + +## Section: A Short History of Git (`history.asc`) + +### Priority: LOW + +- Linux kernel / BitKeeper context doesn't resonate with designers +- Could add: "For design teams, these properties mean: Git handles hundreds of design files, supports non-linear workflows, and is fully decentralized." +- Low priority for revision — historical flavor, doesn't impact learning + +--- + +## Section: First-Time Git Setup (`first-time-setup.asc`) + +### Priority: MEDIUM + +**What Resonates:** +- Setting identity for attribution — designers understand this from design file history + +**What Confuses:** +- Three-level config hierarchy is overly technical for first interaction +- Editor setup (Vim/Emacs/Notepad++) doesn't reflect designer workflows — they typically use VS Code + +**Revision Suggestions:** +- After identity setup, add: "Just like Figma records who made each change, Git attributes every commit to you using this name and email." +- Add note: "If you're using a GUI client (GitHub Desktop, GitKraken), editor configuration is optional." +- Simplify config hierarchy explanation + +--- + +## Section: Installing Git (`installing.asc`) + +### Priority: MEDIUM + +**Revision Suggestions:** +- Add decision tree before platform sections: quick path per OS +- Cut or drastically shorten "Installing from Source" (irrelevant for 95% of designers) +- Add note about GUI clients as alternatives (GitHub Desktop, GitKraken) +- Add verification step (how to confirm installation worked) + +--- + +## Section: The Command Line (`command-line.asc`) + +### Priority: LOW-MEDIUM + +- Acknowledge GUI alternatives for design teams: "GitHub Desktop, GitKraken, or VS Code's built-in Git tools cover most design workflows." +- Soften the CLI-only stance — many designers work exclusively in GUIs + +--- + +## Section: Getting Help (`help.asc`) + +### Priority: LOW-MEDIUM + +- Replace IRC channel references with modern resources (Stack Overflow, Discord, Slack) +- Reorder help methods: put `-h` flag first (quicker, easier) before full manpage options + +--- + +## Cross-Cutting Gaps + +| Gap | Action | +|-----|--------| +| Binary file support | Flag early that `.sketch`, `.psd`, `.figma` files are binary; Git handles them but merging is difficult | +| GUI client recommendations | Name specific tools: GitHub Desktop (simple), GitKraken (visual), VS Code (integrated) | +| Design system collaboration | Frame a design system repository as a compelling use case | +| Branching for design iteration | Preview that branches let designers explore multiple directions simultaneously | + +## Key Analogies to Weave Throughout + +1. Figma version history = Git commits +2. Design tokens = Configuration files +3. Figma shared file = Centralized VCS vs. Git local+sync = Distributed +4. Component variants = Branches +5. Figma Teams library = Shared repository diff --git a/00-notes/02-git-basics/ux-designer-revision-notes.md b/00-notes/02-git-basics/ux-designer-revision-notes.md new file mode 100644 index 000000000..5c4f289b6 --- /dev/null +++ b/00-notes/02-git-basics/ux-designer-revision-notes.md @@ -0,0 +1,110 @@ +# Chapter 2: Git Basics — UX Designer Revision Notes + +## Overview +Chapter 2 is the most critical chapter for UX designer adaptation. It covers the daily Git workflow (init, clone, status, add, commit, diff, log, remotes, tags, undoing). All examples use generic code files — every walkthrough needs design-relevant replacements. + +--- + +## Section: Getting a Repository (`getting-a-repository.asc`) + +### Priority: MEDIUM + +**Issues:** +- Designers rarely init repos — they usually clone existing design system repos +- No mention of `.gitignore` for design tools or large binary design files + +**Revision Suggestions:** +- Add scenario: "Initializing a design system repository" with token files, component guidelines, color palettes +- Add example: `git clone https://github.com/company/design-system-tokens` +- Add sidebar: "Git clone is like downloading a shared Figma project — you get the full history and all branches" + +--- + +## Section: Recording Changes (`recording-changes.asc`) + +### Priority: CRITICAL + +**Issues:** +- Staging area concept is unfamiliar — designers think "save file" not "stage then commit" +- All examples use `.c` files, `README`, `Rakefile` — none resonate with designers +- `.gitignore` section doesn't mention design tool temp files + +**Suggested Analogies:** +- Staging = preparing assets for export; gathering related changes before finalizing +- File status = Figma draft vs. published states +- `git add` = selecting components in Sketch for export + +**Revision Suggestions:** +- Replace all generic examples with design files: `design-tokens.json`, `components-documentation.md`, exported assets +- Add `.gitignore` template for designers: `*.sketch~`, `*.figma_cache`, design software temp folders +- Add tip: "Commit design documentation (text files) separately from exported assets (binary files). Text merges; binary doesn't." +- Add "Commit Messages for Design Teams" subsection with examples: + - Good: "Add button component variants for mobile breakpoints" + - Good: "Update primary color from #1a73e8 to #1f71e8 (accessibility fix)" + - Good: "BREAKING: Rename spacing token `sm` to `small`" + +**New Content Needed:** +- Sidebar: "Git & Design Files Compatibility Matrix" (tokens JSON = mergeable, Figma source = don't commit, SVG exports = version-control friendly) +- Subsection: "Setting Up a Design System Repository" (init, .gitignore, add tokens, add docs, initial commit) + +--- + +## Section: Working with Remotes (`remotes.asc`) + +### Priority: LOW-MEDIUM + +- Add design team remote example: origin = team design system, secondary remote = design token library from another team +- Replace libgit2/grit examples with design system repos + +--- + +## Section: Tagging (`tagging.asc`) + +### Priority: MEDIUM + +- Tags map perfectly to design system releases — leverage this +- Replace generic `v1.4` with: `git tag -a design-system-v2.1.0 -m "Release: new button variants, updated tokens, accessibility audit pass"` +- Add: "For design systems, annotated tags are essential — document what changed so teams know which version they're using" + +--- + +## Section: Undoing Things (`undoing.asc`) + +### Priority: MEDIUM + +- Add design-focused amend scenario: committed button docs, forgot accessibility notes, amend to include them +- Add warning: "Avoid amending commits already shared with the team — it rewrites history" +- Add `git restore` scenario: "Accidentally staged a large Figma export; use `git restore --staged` to unstage without losing the file" + +--- + +## Section: Viewing History (`viewing-history.asc`) + +### Priority: MEDIUM + +- Add design-specific log examples: + - `git log -S "primary-blue" --oneline -- design-tokens.json` (find when a color changed) + - `git log --author="Sarah" --oneline -- components/` (see teammate's component updates) + - `git log --grep="BREAKING" --oneline` (find breaking changes) +- Add tip: "Use consistent commit message prefixes (FEATURE:, FIX:, BREAKING:, DOCS:) to make history searchable" + +--- + +## Section: Git Aliases (`aliases.asc`) + +### Priority: LOW + +- Add design-team sidebar with suggested aliases: + - `git config --global alias.design-changes 'log --oneline -- design-tokens.json components/'` + - `git config --global alias.design-releases 'log --grep="RELEASE" --oneline'` + +--- + +## Cross-Cutting Gaps + +| Gap | Severity | Action | +|-----|----------|--------| +| Binary vs. text files | CRITICAL | Add early subsection explaining what works in Git and what doesn't for design files | +| Design system workflows | HIGH | Thread design system collaboration throughout | +| Commit message standards | MEDIUM | Add guidelines specific to design changes | +| Collaboration context | MEDIUM | Preview branching early so staging/commit workflow doesn't feel isolated | diff --git a/00-notes/03-git-branching/ux-designer-revision-notes.md b/00-notes/03-git-branching/ux-designer-revision-notes.md new file mode 100644 index 000000000..bdf75d5ff --- /dev/null +++ b/00-notes/03-git-branching/ux-designer-revision-notes.md @@ -0,0 +1,121 @@ +# Chapter 3: Git Branching — UX Designer Revision Notes + +## Overview +Chapter 3 covers branching mechanics, merging, rebasing, remote branches, and branch management. The concepts map well to design workflows (parallel explorations, feature isolation), but all examples use generic developer scenarios. + +--- + +## Section: Branches in a Nutshell (`nutshell.asc`) + +### Priority: MEDIUM + +**What Resonates:** Snapshot concept is intuitive for designers (parallels design file versions) + +**What Confuses:** +- Pointer mechanics (SHA-1, HEAD) feel abstract +- "41 bytes" lightweight emphasis doesn't connect to designer workflows + +**Revision Suggestions:** +- Branch as design variant: "Like keeping a mobile-responsive version alongside desktop in Figma" +- HEAD as active artboard: "HEAD = the artboard you're currently editing; checkout = switching artboards" +- Replace generic "testing" branch with `design-tokens-dark-mode` +- Remove 41-byte technical detail — provides no actionable value + +--- + +## Section: Basic Branching and Merging (`basic-branching-and-merging.asc`) + +### Priority: HIGH + +**What Resonates:** The hotfix interruption scenario works for designers (they get interrupted too) + +**Revision Suggestions:** +- Reframe example: "Working on checkout flow redesign (iss53), urgent button color bug reported, create hotfix branch, fix, merge, return to redesign" +- Replace `index.html` conflicts with design token file conflicts (two teammates changed `$button-primary-color` differently) +- Add design system merge scenario: two designers — one added `disabled` state, other added `size` variant +- Mention `git merge --no-ff` as a design team best practice (preserves the record that a whole design system version was integrated) + +**Gaps:** +- No guidance on merge strategy choices for design teams +- No mention of conflict resolution for non-code files (design system JSON, Figma exports) + +--- + +## Section: Branching Workflows (`workflows.asc`) + +### Priority: HIGH + +**What Resonates:** Progressive-stability branching maps perfectly to design system maturity levels + +**Suggested Analogies:** +- `main` = Released design system (in production, stable) +- `develop` = Reviewed, approved designs (queued for next release) +- `feature/button-redesign` = Work-in-progress component (under review) + +**Revision Suggestions:** +- Replace "pu" (proposed updates) with design-relevant naming +- Add design system release workflow example +- Add branch naming conventions for design: `feature/`, `fix/`, `docs/`, `design-system/` +- Address: "Should I create a branch for every component change?" (guidelines on when to branch vs. not) + +--- + +## Section: Rebasing (`rebasing.asc`) + +### Priority: HIGH (conceptually difficult for designers) + +**What Confuses:** Most abstract operation — designers won't have a mental model for "rewinding and replaying commits" + +**Suggested Analogies:** +- Rebase as "replay edits on a cleaner foundation" — like moving a sketch to a different layer +- Merge vs. Rebase as documentation style: Merge = "both states valid"; Rebase = "cleaned-up final story" + +**Revision Suggestions:** +- Design example: "Rebase your new button style onto main to ensure it respects newly merged accessibility updates" +- Add clear guidance: "Should I rebase or merge?" — team culture decision for design teams +- De-emphasize "Rebase When You Rebase" subsection (advanced recovery) — move to troubleshooting +- Simplify patch-id explanation to: "Git can often detect if the same change was applied twice" + +--- + +## Section: Remote Branches (`remote-branches.asc`) + +### Priority: MEDIUM + +**Suggested Analogies:** +- Remote branches as "published" versions: local `button-component` = your draft; `origin/button-component` = published version +- Tracking branches as a "link": "whenever I pull, automatically merge from origin's version" + +**Revision Suggestions:** +- Replace `serverfix` with `design-system-tokens-v3` +- Add collaboration context: what happens when two designers push to the same branch? +- Add PR workflow mention — critical for design review before merging + +--- + +## Section: Branch Management (`branch-management.asc`) + +### Priority: LOW + +- Add branch naming conventions for design teams +- Rename example from generic to `fix/button-hover-state` +- Add guidance on cleanup cadence: how often should a design team prune old branches? + +--- + +## New Content Recommendations + +1. **Branch Naming for Design Teams** — `feature/component-name`, `fix/issue-type`, `docs/`, `design-system/version` +2. **Design System Branching Strategy** — main (released), develop (next release), feature branches for new components +3. **Collaborative Workflows for Design Teams** — multiple designers, PR/review process, managing tokens and component libraries +4. **Design-Specific Merge Conflicts** — JSON design token conflicts, Figma exports, how mergetool helps + +## Example Replacements Throughout + +| Current | Suggested | +|---------|-----------| +| `vim test.rb` | `tokens.json` | +| `index.html` | `button-component.tsx` | +| `email.support@github.com` | design token conflict | +| "issue-tracking system" | "design system version" | +| "deploy" | "release" | diff --git a/00-notes/04-git-server/ux-designer-revision-notes.md b/00-notes/04-git-server/ux-designer-revision-notes.md new file mode 100644 index 000000000..b82cf8d8e --- /dev/null +++ b/00-notes/04-git-server/ux-designer-revision-notes.md @@ -0,0 +1,109 @@ +# Chapter 4: Git on the Server — UX Designer Revision Notes + +## Overview +Chapter 4 covers collaborative Git setup through remote repositories. For UX designers, this chapter is moderately relevant but severely misaligned — most design teams use hosted platforms (GitHub, GitLab), not self-hosted servers. The heavy focus on server administration creates an accessibility barrier. + +**Key structural recommendation:** Reorder chapter to lead with hosted options (currently buried at the end), then present self-hosting as optional. + +--- + +## Section: The Protocols (`protocols.asc`) + +### Priority: MEDIUM + +- Local Protocol parallels shared design asset drives (Dropbox, Google Drive) — make this connection +- Add "Protocol Choice for Design Teams" matrix: small team → GitHub; medium team → GitLab; large org → self-hosted GitLab +- Simplify HTTP protocol cons — irrelevant if using GitHub/GitLab +- Replace security language with designer framing: "Unencrypted transfers — avoid if design files contain proprietary work" + +--- + +## Section: Getting Git on a Server (`git-on-a-server.asc`) + +### Priority: MEDIUM + +- Reframe bare repository: "A bare repository is like a server copy in Figma — not edited directly, only used as a central reference point" +- Replace generic "my_project" with "brand-system.git" or "component-library.git" +- Rename "Small Setups" to "Controlling Who Can Access What" — maps to design governance +- Add scenario: UI designers push, lead designers approve, QA/developers have read-only + +--- + +## Section: SSH Key Generation (`generating-ssh-key.asc`) + +### Priority: MEDIUM (major friction point for non-developers) + +- Lead with hosted alternatives: "Most teams use GitHub/GitLab, which handle SSH setup through their web interface" +- Simplify passphrase section — remove `ssh-agent` discussion +- Add context: "The `.pub` file is safe to share. The other file is secret — like a password." + +--- + +## Section: Setting Up the Server (`setting-up-server.asc`) + +### Priority: LOW (irrelevant for 95% of design teams) + +- Add prominent NOTE: "This section is for organizations with on-premises requirements. Most teams should use GitHub/GitLab instead." +- Replace chmod permission commands with conceptual explanation + +--- + +## Section: Git Daemon (`git-daemon.asc`) + +### Priority: VERY LOW + +- Move to "Advanced/Self-Hosted" appendix — designers almost never self-host public repos + +--- + +## Section: GitWeb (`gitweb.asc`) + +### Priority: LOW + +- Lead with: "If you're using GitHub/GitLab, they provide much better interfaces. Skip this." +- Keep `git instaweb` demo as quick preview option + +--- + +## Section: Smart HTTP (`smart-http.asc`) + +### Priority: LOW-MEDIUM + +- Frame as: "HTTP/HTTPS for teams more comfortable with passwords than SSH keys — but GitLab is easier" + +--- + +## Section: GitLab (`gitlab.asc`) + +### Priority: HIGH (most relevant section for modern design teams) + +- Reframe administration for designers: Users → "Team Members"; Groups → "Design System Teams"; Projects → "Each Git repository" +- Add design system governance: branch protection rules, merge request assignment to senior designers, labels (component update, breaking change) +- Add design artifacts context: GitLab can version design tokens JSON, exported SVGs, design documentation + +--- + +## Section: Third Party Hosted Options (`hosted.asc`) + +### Priority: HIGH (should be moved to position 2 in chapter) + +- Expand with GitHub vs. GitLab comparison table +- Add design-specific features comparison: branch protection, wikis/Pages for docs, integrations with Figma/Slack +- Note: "Works with design files? Yes. Built-in design collaboration? No — use Figma for that." + +--- + +## New Content Needed + +1. **Design System Governance with Git** — role mapping, branch protection, approval workflows, release tagging +2. **Quick Start: GitHub for Design Teams** — create repo, invite team, set protection, define roles (5-minute guide) +3. **Exporting Design Artifacts to Git** — Figma → JSON metadata, Sketch → SVG exports, design tokens → YAML/JSON + +## Tone Shifts + +| Current | Designer-Friendly | +|---------|-------------------| +| "Setting up a Git server" | "Choosing where to host your design system repository" | +| "SSH public key authentication" | "How to securely log in to your repository" | +| "Bare repository" | "Central repository that your team pushes to" | +| "Firewall/port configuration" | "Make sure your team can reach the server" | diff --git a/00-notes/05-distributed-git/ux-designer-revision-notes.md b/00-notes/05-distributed-git/ux-designer-revision-notes.md new file mode 100644 index 000000000..65f4bdfdc --- /dev/null +++ b/00-notes/05-distributed-git/ux-designer-revision-notes.md @@ -0,0 +1,100 @@ +# Chapter 5: Distributed Git — UX Designer Revision Notes + +## Overview +Chapter 5 covers distributed workflows, contributing to projects, and maintaining projects. The contributing section contains the book's most detailed walkthroughs. Most examples use generic code scenarios — all need design-specific rewrites. The email-based patch workflow is largely irrelevant to modern design teams. + +--- + +## Section: Distributed Workflows (`distributed-workflows.asc`) + +### Priority: MEDIUM + +**Revision Suggestions:** +- Add "Design-Specific Workflows" subsection comparing: single-designer projects, small design team (integration-manager), multi-team design system (larger branch structures) +- Rewrite Dictator/Lieutenants intro: "Rarely used by design teams, but appears in orgs like Material Design or Bootstrap where design system decisions go through governance layers." +- Add callout: "As a UX designer, you'll most likely use Integration-Manager (fork + PR) for open-source design projects, or Centralized Workflow for internal team projects." + +--- + +## Section: Contributing to a Project (`contributing.asc`) + +### Priority: HIGH + +**Commit Guidelines (lines 33-99):** +- Remove `git diff --check` for whitespace — irrelevant to designers +- Replace Tim Pope template with design-focused one: `[Component: Button] Updated hover state colors` +- Remove `git add --patch` reference or reframe: "For designers, it's usually easier to commit entire design files at once" + +**Private Small Team (lines 101-325):** +- Replace all file references (`lib/simplegit.rb`) with `design-tokens/colors.json`, `components/Button.sketch` +- Reframe scenario: Sarah redesigns checkout button, Marcus refines form layout, they coordinate pushes + +**Private Managed Team (lines 327-497):** +- Rename branches: `featureA` → `feature/checkout-redesign`, `featureB` → `feature/design-system-forms` +- Add side note: "Ideal when your team is split: one pair working on checkout experience, another improving the form component library." + +**Forked Public Project (lines 499-636):** +- Keep mostly as-is — fork model is intuitive for designers +- Reframe `--squash`: "Collapses all experimental changes into one commit, like flattening iteration layers into a single 'Final Design' layer before exporting" +- Add: "Many design projects (Design Systems, Icon Libraries) use this workflow." + +**Public Project over Email (lines 638-791):** +- Add prominent note: "This section describes an older contribution workflow. Most modern design projects use GitHub/GitLab pull requests instead. Skip unless contributing to a legacy project." +- Consider moving to appendix + +--- + +## Section: Maintaining a Project (`maintaining.asc`) + +### Priority: HIGH + +**Working in Topic Branches (lines 8-29):** +- Replace `sc/ruby_client` with design-relevant names: `sc/icon-overhaul`, `megan/color-palette-v2` +- Add note: "Unlike code, design changes often span multiple file types. Coordinate with your team to ensure changes are consistent." + +**Applying Patches from Email (lines 31-182):** +- Add intro: "Most design projects use GitHub/GitLab pull requests instead. This applies primarily to older or academic projects." + +**Checking Out Remote Branches (lines 184-218):** +- Good as-is — add designer example: "Aisha sends you a link to her design-tokens branch." + +**Determining What Is Introduced (lines 220-294):** +- Add design example: "You want to see exactly what icons Aisha designed that aren't in the main system yet." + +**Integrating Contributed Work (lines 296-402):** +- Add "Design System Release Cycle" example: master = v2.1 (published), develop = ongoing improvements, quarterly merge to master +- Label Large-Merging Workflows as "advanced — for massive projects, not typical design systems" + +**Tagging Releases (lines 428-482):** +- Add: "Include release notes listing new/updated components and token changes" +- Simplify PGP signing: "Optional for design systems. For open-source design systems, signed tags add credibility." + +**Preparing a Release (lines 505-528):** +- Add: `git archive develop --prefix='design-system-v2.1/' --format=zip` for distributing assets to teams without Git + +**The Shortlog (lines 531-557):** +- Add: "Sarah (3): Redesigned form inputs, Added checkbox variations, Updated form spacing." + +--- + +## New Content Needed + +1. **"Design Systems & Collaborative Design" subsection** — repo structure, when to use Git vs. native design tool collaboration, token versioning +2. **Design-Specific Gotchas callout** — binary file merges are impossible; naming conventions matter more in small teams; releases tied to tags +3. **Practical walkthrough scenarios:** + - "You're working on checkout redesign. Teammate is refining form components. How do you coordinate?" + - "You want to contribute icons to Material Design. How?" + - "You're releasing design system v2.0. What do you commit, tag, and archive?" + +## Walkthrough Relevance Summary + +| Walkthrough | Relevance | Action | +|-------------|-----------|--------| +| Private Small Team | High | Revise with design examples | +| Private Managed Team | High | Revise with design context | +| Forked Public Project | High | Keep mostly as-is, clarify for design | +| Public Project over Email | Low | Remove or archive as legacy | +| Applying Patches (git apply/am) | Low-Medium | Trim, recommend PRs instead | +| Checking Out Remote Branches | High | Keep, add design examples | +| Determining What Is Introduced | High | Enhance with asset review examples | +| Tagging/Release/Shortlog | High | Keep, add design system context | diff --git a/00-notes/06-github/ux-designer-revision-notes.md b/00-notes/06-github/ux-designer-revision-notes.md new file mode 100644 index 000000000..e48f07ce0 --- /dev/null +++ b/00-notes/06-github/ux-designer-revision-notes.md @@ -0,0 +1,85 @@ +# Chapter 6: GitHub — UX Designer Revision Notes + +## Overview +Chapter 6 covers GitHub account setup, contributing (forking, PRs), maintaining projects, organizations, and scripting/API. This is one of the most relevant chapters for designers since GitHub is their primary interaction point. However, examples use developer scenarios (Arduino blink project) and miss design-specific workflows. + +--- + +## Section: Account Setup (`1-setting-up-account.asc`) + +### Priority: MEDIUM + +- Add SSH analogy: "Like a trusted device in Figma — once registered, no re-authentication needed" +- Expand email linking: "If you use studio and personal accounts, link both emails so GitHub tracks your total contribution history" +- Add 2FA context for design teams: "Prevents a compromised password from putting all your team's collaborative work at risk" + +--- + +## Section: Contributing (`2-contributing.asc`) + +### Priority: HIGH + +**Forking (lines 5-26):** +- Replace historical baggage note with: "Forking is like duplicating a shared design file to your own workspace" + +**GitHub Flow / Creating a PR (lines 29-195):** +- Replace Arduino blink example with design system contribution: "Maria wants to add a Tooltip component — she forks, branches, adds component files (SVG, CSS, tokens), commits, pushes, opens PR with light/dark mode screenshots" + +**Iterating on a PR (lines 147-205):** +- Add: "You don't need changes to be 'perfect' before opening a PR. Opening early lets your team weigh in on direction." + +**Keeping up with Upstream (lines 224-296):** +- Add design token sync scenario: "If the original design system updates token values, how do I sync my fork?" + +**GitHub Flavored Markdown — Images (lines 476-486):** +- EXPAND this section: "Drag-and-drop images into PR comments for design reviews. Show before/after comparisons, highlight accessibility concerns with annotations, demonstrate responsive behavior." + +**Keeping Forks in Sync (lines 488-548):** +- Add design system context for syncing fork with upstream + +**Gaps:** +- No mention of GitHub's PR diff viewer limitations for binary files (PNGs, SVGs) — designers need to upload screenshots separately +- No guidance on branching strategy for design work +- Missing: how to link PRs to issues + +--- + +## Section: Maintaining a Project (`3-maintaining.asc`) + +### Priority: MEDIUM-HIGH + +- Add design-specific CONTRIBUTING example: icon grid size, accessibility standards, design token naming convention, review criteria, link to Figma +- Expand README for design projects: screenshot/GIF of key components, link to design file, component-to-file mapping, accessibility matrix +- Add new subsection: "Branch Protection for Design Systems" — require PR reviews before merging to main +- Add versioning guidance: use Git tags for design system releases, document changes in CHANGELOG + +--- + +## Section: Managing an Organization (`4-managing-organization.asc`) + +### Priority: MEDIUM + +- Add motivation: "If you're building a design system with 3+ contributors, an organization makes it easier to grant access to multiple repos and maintain consistent governance" +- Expand teams with design examples: `@core-designers` (read/write all), `@contributors` (specific repos), `@stakeholders` (read-only), `@a11y-reviewers` (mentioned for accessibility reviews) + +--- + +## Section: Scripting GitHub (`5-scripting.asc`) + +### Priority: MEDIUM + +- Add design-relevant webhook example: "When someone opens a PR on your design system, automatically post to #design-reviews Slack channel" +- Add GitHub Actions context (successor to Services): "Actions let you validate icon sizes, generate component previews, or deploy documentation" +- Add design-specific validation example: "Check committed SVG files for missing `` elements or poor contrast" +- Simplify API section for designers: "Most automation tasks are easier via GitHub Actions than manual API calls" + +--- + +## Cross-Cutting Themes + +1. **Design Tools Integration (missing entirely):** Storing design exports, linking to Figma, using GitHub Pages for design docs, automated sync +2. **Design Systems as Use Case:** Different workflows than software — visual review, asset naming, documentation priority, versioning +3. **Asynchronous Collaboration:** "Unlike Figma's real-time collaboration, GitHub is async. Write clear PR descriptions with context, include screenshots, expect 24-48 hours for feedback." +4. **Visual Workflows:** Current examples (Arduino blink) don't resonate — need design system PR with component screenshots +5. **GitHub Pages:** Not mentioned but critical for hosting design system documentation +6. **Access Control:** Need role-based explanation (viewer, contributor, maintainer) with design team mapping diff --git a/00-notes/07-git-tools/ux-designer-revision-notes.md b/00-notes/07-git-tools/ux-designer-revision-notes.md new file mode 100644 index 000000000..b60982705 --- /dev/null +++ b/00-notes/07-git-tools/ux-designer-revision-notes.md @@ -0,0 +1,131 @@ +# Chapter 7: Git Tools — UX Designer Revision Notes + +## Overview +Chapter 7 is the largest tools chapter with 38 walkthroughs. Relevance varies widely — stashing, reset, submodules, and interactive staging are highly relevant; bundling, signing, and advanced filter-branch are low relevance. All examples use code files and need design-specific replacements. + +--- + +## Section: Advanced Merging (`advanced-merging.asc`) + +### Priority: HIGH + +- Replace `hello.rb` with a realistic design scenario (design token JSON, component definitions) +- Add design system subsection: merge conflict resolution for `tokens.json` or `components.yaml` +- Introduce three-tree analogy: "component in your local artboard (working directory), version in shared library (HEAD), library version someone else committed (incoming branch)" +- De-emphasize manual `dos2unix` preprocessing (too code-specific) + +--- + +## Section: Stashing and Cleaning (`stashing-cleaning.asc`) + +### Priority: MEDIUM-HIGH + +- Replace `index.html`/`lib/simplegit.rb` with `design-tokens.json`, `icons/` directory, component metadata +- Add "Design Iteration Pausing" scenario: stash new icon set while shipping a production bug fix +- Expand branch-from-stash: "Perfect when you start design exploration on main and realize it should be a feature branch" +- Clarify `git clean` dangers: "If design exports were untracked, `git clean` removes them permanently" + +--- + +## Section: Reset Demystified (`reset.asc`) + +### Priority: MEDIUM + +- Redesign three-tree metaphor: HEAD = last published design system version, Index = staged for next release, Working Directory = current design canvas +- Replace `file.txt` with `design-system-v1.0.json` +- Add practical scenario: staged both `typography.tokens.json` and `colors.tokens.json`, want to commit only typography now +- Expand squashing: collapse "Add heading font size" + "Oops, wrong size" + "Fix heading size" into clean "Update heading typography" + +--- + +## Section: Rewriting History (`rewriting-history.asc`) + +### Priority: MEDIUM + +- Add prominent shared-history warning for designers on shared repos +- Design scenario for amend: "Committed 'Update button styles' but forgot focus state CSS" +- Design scenario for split: "One commit refactors spacing tokens AND updates button styles — split for separate review" +- De-emphasize filter-branch — move to appendix; frame as "if you accidentally committed large .psd files" + +--- + +## Section: Interactive Staging (`interactive-staging.asc`) + +### Priority: MEDIUM + +- Replace file names with design files: `design-system/colors.json`, `icons/icon-library.json` +- Add "Design Token Staging" use case: `tokens.json` has updates to both color and typography — stage only color changes for current PR + +--- + +## Section: Debugging (`debugging.asc`) + +### Priority: LOW-MEDIUM + +- Git blame: "A color value in your design tokens changed three commits ago and broke styles. Use `git blame colors.json` to find which commit introduced it." +- Git bisect: mark as optional/advanced — "If you're maintaining a large design system..." + +--- + +## Section: Searching (`searching.asc`) + +### Priority: LOW-MEDIUM + +- Reframe for design system maintenance: "Find all components using the old `primary-blue` token" +- Mark as "more relevant for design system maintainers than individual designers" + +--- + +## Section: Signing (`signing.asc`) + +### Priority: LOW + +- Add one line: "If your organization requires signed commits for compliance, configure GPG here. Most design teams don't use this." + +--- + +## Section: Bundling (`bundling.asc`) + +### Priority: VERY LOW + +- UX designers rarely transfer repos offline — remove or move to appendix + +--- + +## Section: Submodules (`submodules.asc`) + +### Priority: MEDIUM-HIGH + +- Keep and expand with design example: "Your main product repo includes a design system as a submodule. Update submodule pointers when the design system releases a new version." + +--- + +## Section: Replace / Subtree Merges + +### Priority: VERY LOW + +- Too advanced for most designers — mark as "For Repository Maintainers Only" + +--- + +## Revision Priority Summary + +| Section | Relevance | Priority | Action | +|---------|-----------|----------|--------| +| Advanced Merging | Low | HIGH | Replace code examples; add design system scenario | +| Stashing & Cleaning | Medium-High | MEDIUM-HIGH | Add design-specific examples | +| Reset | High | MEDIUM | Redesign metaphor with design vocabulary | +| Rewriting History | Medium | MEDIUM | Add caution; de-emphasize filter-branch | +| Interactive Staging | High | MEDIUM | Replace examples with design files | +| Debugging | Medium | LOW-MEDIUM | Keep blame; soften bisect | +| Searching | Medium | LOW-MEDIUM | Reframe for system maintainers | +| Signing & Bundling | Low | LOWEST | Remove or appendix | +| Submodules | Medium-High | MEDIUM-HIGH | Expand with design system use case | + +## New Walkthroughs to Create + +1. "Design System Version Management" — merge commits and submodules +2. "Resolving Design File Merge Conflicts" — practical token/component walkthrough +3. "Staging Design Changes Selectively" — `git add -p` for color vs. typography tokens +4. "Finding When a Design Token Changed" — `git blame` on tokens +5. "Undoing a Design System Release" — `git reset` or `git revert` for breaking changes diff --git a/00-notes/08-customizing-git/ux-designer-revision-notes.md b/00-notes/08-customizing-git/ux-designer-revision-notes.md new file mode 100644 index 000000000..99299a43b --- /dev/null +++ b/00-notes/08-customizing-git/ux-designer-revision-notes.md @@ -0,0 +1,105 @@ +# Chapter 8: Customizing Git — UX Designer Revision Notes + +## Overview +Chapter 8 covers Git configuration, attributes, hooks, and policy enforcement. Several sections have high relevance for design workflows (binary file handling, commit templates, hooks for validation) but are framed entirely for developers. + +--- + +## Section: Git Configuration (`config.asc`) + +### Priority: MEDIUM + +**Keep/Expand:** +- External merge/diff tools (P4Merge) — visual comparison is intuitive for designers +- Commit templates — reframe for design workflows +- Color configuration — designers naturally understand terminal colors + +**Cut/Minimize:** +- `core.autocrlf` and `core.whitespace` — irrelevant to designers shipping design files +- Server-side config — designers don't administer servers + +**Revision Suggestions:** +- Expand diff tools with design token file diffs (JSON/YAML with colors, typography) +- Replace commit template `[Ticket: X]` with: `[Component: Button/Primary]` or `[Design System: v2.1]` +- Add new subsection: "Git Config for Design Workflows" — aliases for design-file diffs, ignoring cache files + +--- + +## Section: Git Attributes (`attributes.asc`) + +### Priority: HIGH + +**High Relevance for Designers:** +- Binary file handling — designers work with binary files constantly (PNG, SVG, Sketch) +- Image diffing with EXIF — designers understand metadata +- Export-ignore — directly applicable: "Exclude design source files from exports but version them in Git" + +**Cut/Replace:** +- C code indentation filter — replace with design-relevant filter (SVG optimization or token transformation) +- Complex Ruby keyword expansion — simplify or replace with design metadata injection + +**Revision Suggestions:** +- Expand binary file identification with design-specific examples: `.sketch`, `.xd`, `.psd`, Figma JSON +- Include a `.gitattributes` template for design repos +- Replace C indent with: "Design token transformation filter — convert JSON to CSS variables on checkout" +- Emphasize export-ignore: "Keep .sketch files in Git but export clean SVG/PNG without source clutter" +- Add merge strategy note: "Design files should use `merge=ours` — each designer keeps their local version" + +--- + +## Section: Git Hooks (`hooks.asc`) + +### Priority: MEDIUM + +**Front-load useful hooks:** +- pre-commit, commit-msg, post-commit first +- De-emphasize email workflow hooks (applypatch-msg, etc.) — designers never use `git am` + +**Add hook use cases:** +- "Use pre-commit to lint design files before committing" +- "Use commit-msg to validate design update descriptions" +- "Use post-commit to trigger design system builds" + +**Provide copy-paste hook scripts** — designers can't write Ruby/Perl + +--- + +## Section: Policy Enforcement (`policy.asc`) + +### Priority: MEDIUM-HIGH + +**Simplify hook examples drastically:** +- Replace full Ruby scripts with pseudo-code or simpler shell scripts +- Add heavy comments explaining each line + +**Create design-specific examples:** +- Commit-msg hook: validate `[Component: ComponentName]` pattern instead of generic `[ref: XXXX]` +- ACL example: Admins = edit anything; Designers = edit screens not tokens; Docs = only edit docs +- Emphasize client-side hooks over server-side (designers care about local validation) + +**Testing section (lines 217-280):** +- Keep — demonstrates actual hook behavior with push attempts +- Add design example: documentation writer trying to modify files outside ACL scope + +**Cut/Simplify:** +- Pre-rebase hook — too complex for designers; present as "advanced tool for team leads" +- Dense Ruby ACL scripts — provide ready-made scripts designers can copy + +--- + +## Content Gaps + +| Gap | Action | +|-----|--------| +| Binary design file handling | Add subsection on storing .sketch, .xd, Figma exports; LFS considerations | +| Design system versioning | Using tags for releases, managing token versions alongside component code | +| Design token management | Storing tokens in Git, version-controlling JSON/YAML, syncing with design tools | +| Asset management | Storing icons, illustrations in Git; organizing and versioning asset libraries | +| Design documentation in Git | Keeping design docs in sync with component code | + +## New Content Needed + +1. `.gitattributes` template for design repos with comments explaining each rule +2. "Design Token Versioning with Git" subsection combining attributes and config +3. Ready-made hook scripts designers can use as-is +4. "Design System Collaboration with Git" walkthrough combining config, attributes, and hooks diff --git a/00-notes/09-git-and-other-scms/ux-designer-revision-notes.md b/00-notes/09-git-and-other-scms/ux-designer-revision-notes.md new file mode 100644 index 000000000..de8d2b7f7 --- /dev/null +++ b/00-notes/09-git-and-other-scms/ux-designer-revision-notes.md @@ -0,0 +1,92 @@ +# Chapter 9: Git and Other Systems — UX Designer Revision Notes + +## Overview +Chapter 9 covers using Git as a client for other VCS (Mercurial, Perforce, Subversion) and importing from those systems. For UX designers, this chapter has low-to-moderate relevance — only SVN migration is plausible in enterprise design contexts. All sections lack design tool analogies and binary asset handling guidance. + +--- + +## Section: Git and Mercurial (`client-hg.asc`) + +### Priority: VERY LOW + +- Mercurial is extremely rare in design team environments +- Consider moving to appendix or adding disclaimer: "Mercurial is rarely used in design workflows" +- If kept, add front-matter: "This section applies only if your organization uses Mercurial" + +--- + +## Section: Git and Perforce (`client-p4.asc`) + +### Priority: LOW-MEDIUM + +- Cut Git Fusion infrastructure details to 5 lines: "Git Fusion requires server-side setup. Contact your DevOps team." +- Add UX-specific note: "More common: your code is in Perforce, design tokens are in Git" +- Add "Working with Assets in Perforce" note about binary file sync differences +- git-p4 is slightly more relevant — add design token update example + +--- + +## Section: Git and Subversion (`client-svn.asc`) + +### Priority: MEDIUM (highest relevance of the three bridges) + +- SVN is the most likely legacy system for design team assets (enterprise archives) +- Add context upfront: "SVN is common in enterprise design environments" +- Create new subsection: "Working with Design Files in SVN" — binary handling, batch commits +- Reframe branching issues with design example: `redesign/components` branch +- Cut/collapse SVN Style History and SVN Annotation (rarely used by designers) + +--- + +## Section: Custom Importer (`import-custom.asc`) + +### Priority: LOW + +- Add intro note: "Applies if migrating from ad-hoc versioning (directory snapshots). Modern teams should use native design tool versioning." +- Add design example: "Your team stored versions as `backup_2023_01_15/components.sketch`" +- Simplify code walkthrough — keep structure, cut low-level fast-import explanation + +--- + +## Section: Importing from Mercurial (`import-hg.asc`) + +### Priority: VERY LOW + +- Reduce to 5-line pointer or remove entirely +- Add disclaimer: "Mercurial migrations are rare in design workflows" + +--- + +## Section: Importing from Perforce (`import-p4.asc`) + +### Priority: LOW-MEDIUM + +- Add "What to Migrate" subsection: full history vs. latest state only +- Add: "For design assets where old versions are less valuable, import only latest state" + +--- + +## Section: Importing from Subversion (`import-svn.asc`) + +### Priority: MEDIUM-HIGH + +- Add "Pre-Import Planning" subsection: check total size (>100MB → consider Git LFS), identify design files for special handling +- Replace "Peg-Revisions" with: "Delete branch names with `@` suffixes — they're SVN-specific" +- Add "Handling Large Design Files" post-cleanup: consider Git LFS for files >50MB + +--- + +## Cross-Cutting Gaps + +| Gap | Action | +|-----|--------| +| Design tool analogies absent | Add sidebar: "How Git Differs from Your Design Tools" | +| Binary asset handling never addressed | Add "Binary Assets" note: Git LFS often necessary for design files | +| Real UX scenarios missing | Add: "I need to version my design system repo" / "My tokens are in code" | +| Terminology barriers | Add glossary mapping SVN/Mercurial/Perforce terms to Git equivalents | + +## Recommended New Content + +1. **"Working with Design Files Across VCS Boundaries"** — when designers encounter legacy VCS, binary handling, decision tree for Git suitability +2. **VCS Terminology Glossary** — mapping terms across systems +3. **UX-Specific Workflow Examples** — SVN design archive migration, Perforce token sync diff --git a/00-notes/10-git-internals/ux-designer-revision-notes.md b/00-notes/10-git-internals/ux-designer-revision-notes.md new file mode 100644 index 000000000..3c4922f5b --- /dev/null +++ b/00-notes/10-git-internals/ux-designer-revision-notes.md @@ -0,0 +1,110 @@ +# Chapter 10: Git Internals — UX Designer Revision Notes + +## Overview +Chapter 10 introduces Git's internal architecture. Currently written for infrastructure engineers, not designers. The core insight: revision should reframe internals through data recovery, collaboration reliability, and practical troubleshooting — not cryptography and protocol mechanics. + +--- + +## Section: Plumbing and Porcelain + +### Priority: HIGH (reframe, don't cut) + +- Add designer-focused opening: "While designers use porcelain commands (commit, push, pull), understanding plumbing reveals how Git prevents data loss — critical when collaborating on high-stakes design assets." +- Reframe `.git` directory exploration: "When you accidentally delete a branch or overwrite changes, Git hasn't lost your work — it's just not visible through normal commands." + +--- + +## Section: Git Objects + +### Priority: HIGH (simplify heavily) + +- Replace "content-addressable filesystem" with design analogy: "Every component gets a unique fingerprint based on its exact appearance. If the button design is identical in two versions, Git recognizes it's the same object." +- Replace `test.txt` with design-specific examples (icon versions, token snapshots) +- Remove or drastically simplify Ruby SHA-1 object storage section (pure cryptography, zero design relevance) +- Expand tree objects with design context: trees represent complete file structure at a moment — "the folder structure in your project snapshot" + +--- + +## Section: Git References + +### Priority: HIGH + +- Reframe: "Branches are just labels — like naming layers in Figma" +- Simplify HEAD: "HEAD is 'where you are now.' When you switch branches, HEAD updates." +- Enhance tags with design example: "Tag your design system as `v2.0` when releasing updated component library" +- Add collaboration context to remotes: "When you push to GitHub, `origin/main` is your local tracking branch — fetch to sync" + +--- + +## Section: Packfiles + +### Priority: MEDIUM-HIGH + +- High relevance for designers with large files — connect to clone/push performance +- Add opening: "When you repeatedly modify a large design file, Git stores one complete version and compressed change records — keeping your repo lean" +- Replace `repo.rb` with `icon-set.svg` or `design-tokens.json` +- Clarify `git gc` is automatic — designers don't need to run it manually +- Add callout: "If your design repo becomes >500MB, consider Git LFS, splitting files, or archiving old versions" + +--- + +## Section: Maintenance and Data Recovery + +### Priority: MEDIUM-HIGH (highest practical relevance) + +- Add reassurance opening: "Accidentally deleted a design commit? Git typically preserves your work for weeks via the reflog." +- Keep reflog walkthrough mostly intact — add scenario header: "You force-reset master, losing recent design changes" +- Simplify fsck: "If reflog is deleted, `git fsck --full` finds dangling commits. Create a branch from one to recover." +- Restructure large object removal: move to "Advanced" section, explain alternatives first (`.gitignore`, Git LFS, delete-and-recreate branch) +- Add "Best Practices for Preventing Data Loss" subsection + +--- + +## Section: Transfer Protocols + +### Priority: LOW-MEDIUM + +- Make optional for designers: "This section is for advanced troubleshooting. Most designers can skip this." +- Replace protocol details with practical troubleshooting: "Why does `git clone` fail?", "Why does push hang?", "SSH vs. HTTPS?" +- Simplify dumb protocol: "Rarely used today; all modern hosting uses smart protocol" + +--- + +## Section: The Refspec + +### Priority: MEDIUM + +- Add designer-focused opening: "Refspecs define which branches you fetch. Useful for managing large multi-branch design systems." +- Add design example: "Your design system has 20 branches (one per component). Fetch only `main` and `buttons-v2`." + +--- + +## Section: Environment Variables + +### Priority: LOW + +- Keep only designer-relevant vars: `GIT_EDITOR`, `GIT_TRACE` (debugging), `GIT_SSH_COMMAND` +- Remove pathspecs, advanced networking, miscellaneous +- Add debugging scenarios: "My `git clone` hangs — use `GIT_TRACE=true`" + +--- + +## Revision Priority Summary + +| Section | Priority | Key Change | +|---------|----------|------------| +| Plumbing & Porcelain | HIGH | Add "why" context for data recovery | +| Objects | HIGH | Replace examples; cut Ruby SHA-1; emphasize immutability | +| References | HIGH | Clarify branches as pointers; design collaboration examples | +| Packfiles | MEDIUM-HIGH | Connect to performance; use design asset examples | +| Maintenance & Recovery | MEDIUM-HIGH | Expand reassurance; simplify walkthroughs | +| Transfer Protocols | LOW-MEDIUM | Make optional; add troubleshooting context | +| Environment Variables | LOW | Keep only designer-relevant vars | +| Refspec | MEDIUM | Add design system branch example | + +## Pedagogical Improvements + +1. Lead with "Why" not "What" — each section should open with why designers care +2. Use consistent design-focused examples throughout (Figma, Sketch, tokens, component libraries) +3. Add reassurance about Git's safety features (reflog, immutability) +4. Reduce cognitive load — cut or defer highly technical content diff --git a/00-notes/A-git-in-other-environments/ux-designer-revision-notes.md b/00-notes/A-git-in-other-environments/ux-designer-revision-notes.md new file mode 100644 index 000000000..c7a8e3b54 --- /dev/null +++ b/00-notes/A-git-in-other-environments/ux-designer-revision-notes.md @@ -0,0 +1,96 @@ +# Appendix A: Git in Other Environments — UX Designer Revision Notes + +## Overview +Appendix A covers terminal shells (Bash, Zsh, PowerShell) and IDE/editor integrations (VS Code, Sublime Text, JetBrains, GUIs). For designers, the IDE/GUI sections are most relevant. Shell configuration is intimidating and less applicable. A decision tree at the start would help designers choose the right section. + +--- + +## Structural Recommendation + +Add a **decision tree** at the beginning: +- "Are you on macOS?" → Zsh section +- "Are you on Windows?" → PowerShell section or GitHub Desktop +- "Are you using VS Code?" → VS Code section +- "Building a design system with React?" → WebStorm section + +--- + +## Section: Graphical Interfaces (`guis.asc`) + +### Priority: MEDIUM-HIGH + +- Add design system branching strategy context +- Clarify when to use Git vs. cloud design tools (Figma's built-in versioning) +- Add `.gitignore` guidance for design artifacts +- Mention design-specific hosting (GitHub vs. Figma version control vs. Abstract/Plant) + +--- + +## Section: VS Code (`visualstudiocode.asc`) + +### Priority: MEDIUM + +- Expand for design token workflows and design system documentation +- Add: "diff in gutter" is like Figma's "track changes" +- Add: when VS Code Git integration is insufficient (binary design files) +- Mention Pull Request extension for design reviews + +--- + +## Section: Sublime Text (`sublimetext.asc`) + +### Priority: LOW + +- Clarify Sublime Merge integration +- Consider recommending VS Code instead for designers + +--- + +## Section: JetBrains IDEs (`jetbrainsides.asc`) + +### Priority: MEDIUM + +- Focus on WebStorm (most relevant to designers building design systems) +- Explain Version Control ToolWindow +- Add design system component workflow example + +--- + +## Section: Bash (`bash.asc`) + +### Priority: LOW + +- Shell configuration is intimidating for designers +- Add context: "The prompt showing branch name prevents committing to the wrong branch — a safety check" +- Simplify technical explanations (`\w`, `\$`) + +--- + +## Section: Zsh (`zsh.asc`) + +### Priority: LOW + +- Note that Zsh is macOS default post-Catalina +- Reference oh-my-zsh as the beginner-friendly path (rather than manual vcs_info config) +- Zsh's graphical tab completion is like Figma's component picker — add this analogy + +--- + +## Section: PowerShell (`powershell.asc`) + +### Priority: LOW + +- Condense ExecutionPolicy to single command — don't explain scopes in detail +- Suggest GitHub Desktop for Windows designers as simpler alternative + +--- + +## Cross-Cutting Gaps + +| Gap | Action | +|-----|--------| +| Design file version control limitations | Git works best with text; design files are binary/proprietary | +| Collaborative design workflows | When to use Git vs. Figma real-time collaboration | +| Design system branching | Managing v1, v2, v3 with branches or tags | +| Asset management | Versioning icons, illustrations, fonts in Git (Git LFS, separate repos, CDN) | +| Tool decision guidance | No help choosing between shell vs. editor, or between editors | diff --git a/00-notes/B-embedding-git/ux-designer-revision-notes.md b/00-notes/B-embedding-git/ux-designer-revision-notes.md new file mode 100644 index 000000000..3fe81e93f --- /dev/null +++ b/00-notes/B-embedding-git/ux-designer-revision-notes.md @@ -0,0 +1,77 @@ +# Appendix B: Embedding Git — UX Designer Revision Notes + +## Overview +Appendix B covers Git libraries for embedding in applications (Libgit2, JGit, go-git, Dulwich, command-line). Currently targets developers building Git-integrated applications. For UX designers, this is relevant in two narrow scenarios: (1) designing applications that embed Git, or (2) understanding how design tools use Git internally. + +**Core recommendation:** Reframe from "how to code Git integration" to "where Git integration appears in design tools and how it affects UX." + +--- + +## Section: Command-Line Git (`command-line.asc`) + +### Priority: LOW (reframe entirely) + +- Replace technical constraints (text parsing, process management) with UX design patterns for Git integration +- Add: "If you're designing applications that integrate Git, expect these user needs: commit messages, branch switching, pull/push, conflict resolution" +- Reference existing products as design patterns: GitHub Desktop, GitKraken, Sublime Merge + +--- + +## Section: Libgit2 (`libgit2.asc`) + +### Priority: LOW-MEDIUM + +- Note it powers GitHub Desktop, GitKraken, Sublime Merge — tools designers actually use +- Add after Rugged example: "In a design tool, users would never see this code — they'd click 'Save Version'" +- Reduce "Other Bindings" subsection — move to reference page +- Cut advanced ODB backends detail or move to footnote + +--- + +## Section: JGit (`jgit.asc`) + +### Priority: LOW + +- Add callout: "plumbing = low-level UX (users handle Git details); porcelain = high-level UX (abstracted away)" +- Note for designers: "A tool using porcelain APIs could auto-merge compatible design token changes (simpler UX)" +- Keep Maven setup for developers; add note that designers can skip to concepts + +--- + +## Section: go-git (`go-git.asc`) + +### Priority: LOW + +- Add context: "Go powers CLI tools designers might use — design token generators, SVG optimization in CI" +- Condense "Advanced Functionality" to plain English: "The tool can optionally store design files in alternative locations" + +--- + +## Section: Dulwich (`dulwich.asc`) + +### Priority: LOW-MEDIUM (most designer-relevant due to Python) + +- Python is widely used in design automation tools and Figma plugins +- Reframe: "Dulwich enables Python-based design tools to add Git versioning" +- Add example: "A Python script that auto-commits design file changes when exporting SVGs" +- Add sidebar: "Common in: Figma plugins, design token scripts, automation tools" + +--- + +## Recommended Restructuring + +**New framing (replace intro):** +> "This appendix is relevant to UX designers in two scenarios: (1) if you're designing applications that embed Git version control, or (2) if you're using Git-aware design tools and want to understand how they work." + +**New section order:** +1. Overview: "Where Git Integration Appears in Design Tools" +2. Command-Line Git → rename to "Git UI Patterns in Applications" +3. Libgit2 → "The Most Popular Git Library" (powers GitHub Desktop) +4. Dulwich → "Git in Python-Based Design Tools" +5. JGit & go-git → consolidate as "Git in Backend Services" (less relevant) + +## Content Gaps + +- No mention of how Git-aware design tools handle version control UX +- No discussion of Git integration with Figma, Sketch, Adobe XD +- Missing: decision framework for when to advocate for Git integration in design tools diff --git a/00-notes/C-git-commands/ux-designer-revision-notes.md b/00-notes/C-git-commands/ux-designer-revision-notes.md new file mode 100644 index 000000000..26d854c65 --- /dev/null +++ b/00-notes/C-git-commands/ux-designer-revision-notes.md @@ -0,0 +1,85 @@ +# Appendix C: Git Commands — UX Designer Revision Notes + +## Overview +Appendix C is a reference listing of Git commands grouped by purpose. For designers, the key revision is to reorganize by workflow (not command taxonomy), highlight the ~15 essential commands, cut irrelevant sections (email workflows, plumbing), and add design-specific scenarios. + +--- + +## Command Relevance Tiers + +### CRITICAL (must understand) +`git init`, `clone`, `branch`, `checkout`, `add`, `commit`, `status`, `log`, `push`, `pull`, `merge`, `tag`, `stash` + +### IMPORTANT (should know) +`git diff`, `reset`, `rm`, `remote`, `fetch`, `show`, `revert`, `clean` + +### NICE-TO-HAVE (contextual) +`git cherry-pick`, `bisect`, `grep`, `blame`, `difftool`, `mergetool`, `config` + +### IRRELEVANT (remove for designer edition) +`git am`, `apply`, `format-patch`, `send-email`, `request-pull`, `imap-send` (email workflows — 48 lines to cut), `git svn`, `fast-import` (external VCS — 16 lines), `ls-files`, `ls-remote`, `rev-parse` (plumbing — 12 lines), `git fsck`, `reflog`, `filter-branch` (administrative) + +--- + +## Structural Recommendation + +Reorganize from command taxonomy to **workflow-based structure:** + +1. **Getting Started** (init, clone, config) +2. **Daily Design Work** (branch, checkout, add, commit, status, diff) +3. **Collaborating** (push, pull, fetch, merge, stash) +4. **Design System Releases** (tag, archive) +5. **Troubleshooting** (reset, revert, log, blame, show) +6. **Advanced** (rebase, cherry-pick, bisect, etc.) + +--- + +## Key Revisions by Section + +**Setup and Config (lines 19-88):** +- Cut massive editor config table (32 lines) — replace with one-liner linking to Chapter 1 + +**Basic Snapshotting (lines 123-222):** +- Reframe `git add`: "Select which artboards/components to include in your export — only staged changes get saved" +- Add design analogy for diff: "Side-by-side component comparison, like Figma's before/after" + +**Branching and Merging (lines 223-313):** +- Expand `git merge` to one paragraph: "When your design iteration is ready, `git merge` combines it back into main. Example: merge `feature/dark-mode` into production design." +- Add design review mention before merging + +**Sharing and Updating (lines 315-387):** +- Reframe `git pull`: "Download the latest design changes from the team repo and merge them into your local branch. Use every morning to stay synchronized." + +**Inspection and Comparison (lines 389-414):** +- Reframe `git log`: "See your design evolution — use `--oneline --graph` to visualize parallel designer work" +- Reframe `git blame`: "Find out who changed a specific design element" + +**Debugging (lines 416-438):** +- Reframe as "understanding your design history" not "debugging code" + +**Email Workflows (lines 472-519):** +- DELETE entirely — replace with: "Modern teams use GitHub/GitLab Pull Requests. See Chapter 6." + +**External Systems (lines 520-535):** +- DELETE — irrelevant unless migrating from SVN + +**Plumbing Commands (lines 570-581):** +- DELETE — add note: "For advanced internals, see Chapter 10" + +--- + +## Missing Content for Designers + +1. **`.gitignore` for design workflows** — exclude temp files, exports, dependencies +2. **Design file merge conflicts** — "Design files conflict differently than code. Merge tools struggle with binary formats." +3. **Commit message conventions** — design-specific examples and prefixes +4. **Branching strategy** — main (production), feature/ (WIP), experimental/ (exploration) +5. **Recovering accidentally deleted designs** — designer-friendly reflog guidance +6. **Quick reference table** — 10 essential commands mapped to designer use cases + +--- + +## Estimated Impact +- Cut ~80 lines of irrelevant content +- Reduce from ~582 lines to ~350 lines +- Significantly improve clarity and relevance for UX designers From a12780729b2855a0ccd7d77f02390be3a77aad72 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Fri, 20 Mar 2026 15:02:31 +0000 Subject: [PATCH 09/18] Add unified storyline analysis for UX designer edition Proposes "Meadow" wellness app design system as a continuous narrative thread across all chapters. Maps four characters, a product timeline, and artifact continuity to every existing revision recommendation. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/storyline-analysis.md | 233 +++++++++++++++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 00-notes/storyline-analysis.md diff --git a/00-notes/storyline-analysis.md b/00-notes/storyline-analysis.md new file mode 100644 index 000000000..e960aeb34 --- /dev/null +++ b/00-notes/storyline-analysis.md @@ -0,0 +1,233 @@ +# Common Storyline Analysis + +## Problem: Fragmented Examples Across Chapters + +The current revision notes propose disconnected examples across chapters: + +- **Inconsistent characters**: Sarah (Ch5), Marcus (Ch5), Aisha (Ch5), Maria (Ch6), Megan (Ch5 branch name only) — none carry between chapters +- **Disconnected artifacts**: button components, checkout flows, form components, icon sets, and design tokens appear repeatedly but without continuity +- **No progression**: each chapter reinvents its scenario from scratch, so readers never build on prior context + +A unified storyline solves all three problems. Readers follow one product, one team, and one set of artifacts from Chapter 1 through Chapter 10, with each chapter advancing the story naturally. + +--- + +## Proposed Storyline: "Meadow" — A Design System for a Wellness App + +### Why This Product +- A wellness/health app is visually rich (illustrations, icons, color palettes, typography) — maximizes design artifact variety +- Broad enough to require multiple component types (forms, cards, navigation, charts, onboarding flows) +- Relatable across industries — not tied to fintech, e-commerce, or gaming jargon +- Naturally involves accessibility concerns (contrast, screen readers, motion sensitivity) + +### The Team + +| Character | Role | Personality Trait | Introduced | +|-----------|------|-------------------|------------| +| **Nora** | Lead Designer / Design System Owner | Methodical, sets standards | Ch1 | +| **Sam** | UI Designer (components) | Moves fast, sometimes forgets to commit cleanly | Ch2 | +| **Priya** | Visual Designer (illustrations, icons) | Works with large binary files | Ch3 | +| **Dev (the developer)** | Frontend Engineer | Bridge between design and code — consumes tokens | Ch5 | + +Four characters are enough to demonstrate solo work, pair collaboration, team coordination, and cross-functional handoff. Each has a trait that naturally triggers specific Git scenarios. + +### The Product Timeline + +The storyline maps to a realistic product lifecycle. Each chapter picks up where the prior left off: + +| Chapter | Story Phase | What Happens | +|---------|-------------|--------------| +| **Ch1** | Discovery | Nora discovers version control after losing a week of work when her "final-v3-REAL" folder gets overwritten. She learns what Git is and installs it. | +| **Ch2** | Foundation | Nora creates the Meadow design system repo. Adds `design-tokens.json`, component documentation, and exported assets. Learns status, add, commit, diff, log. Her first `.gitignore` excludes `.sketch` temp files. | +| **Ch3** | Exploration | Sam joins. They use branches to explore a dark mode variant (`feature/dark-mode`) while Nora continues refining the light theme on `main`. Their first merge conflict: both edited `colors.json`. | +| **Ch4** | Infrastructure | The team picks GitHub to host the repo (not a bare server). Nora sets up branch protection so `main` requires a review before merge. | +| **Ch5** | Collaboration | Priya joins for an icon overhaul. Three designers coordinate: Nora on tokens, Sam on components, Priya on icons. They practice the integration-manager workflow. First design system release (`v1.0`). | +| **Ch6** | Open Source | Meadow's design system goes public on GitHub. An external contributor (Marcus) forks it and submits a PR adding a Tooltip component. Nora reviews, requests changes, merges. | +| **Ch7** | Maturity | The team handles real-world complexity: Sam stashes half-finished button states to fix a production color bug. Priya uses `git blame` to find when an icon color changed. Nora uses interactive rebase to clean up a messy token migration history. | +| **Ch8** | Customization | Nora configures `.gitattributes` for binary design files, sets up a commit message template (`[Component: X]`), and adds a pre-commit hook that validates token JSON syntax. | +| **Ch9** | Migration | The team migrates legacy brand assets from an SVN archive into the Git repo. They handle large binary files and history cleanup. | +| **Ch10** | Mastery | Sam accidentally force-resets `main`, losing recent commits. Nora uses reflog to recover. The chapter demystifies Git internals through the lens of "your work is never truly lost." | +| **App A** | Tooling | The team evaluates VS Code vs. GitHub Desktop vs. CLI for their workflow. Decision tree based on comfort level. | +| **App B** | Integration | The team considers how design tools (Figma plugins, token pipelines) integrate with Git under the hood. | +| **App C** | Reference | Quick-reference card organized by Meadow workflow phases, not command taxonomy. | + +--- + +## Artifact Continuity Map + +These artifacts appear and evolve across chapters, giving readers anchoring reference points: + +### Core Files (appear 5+ chapters) + +| Artifact | First Appears | Evolves Through | Purpose | +|----------|---------------|-----------------|---------| +| `design-tokens.json` | Ch2 (created) | Ch3 (dark mode added), Ch5 (v1.0 release), Ch7 (migration cleanup), Ch8 (validation hook) | The primary "code-like" design file — mergeable, diffable, central to the system | +| `colors.json` (subset of tokens) | Ch2 (initial palette) | Ch3 (merge conflict), Ch5 (coordinated update), Ch7 (blame for change), Ch8 (diff config) | Most relatable file for designers — color values changing | +| `components/button/` | Ch2 (first component) | Ch3 (dark mode variant), Ch5 (Sam's work), Ch7 (stash scenario), Ch8 (commit template) | The universal UI component — every designer understands buttons | +| `.gitignore` | Ch2 (created) | Ch8 (expanded for design tools) | Practical file designers need immediately | +| `README.md` | Ch2 (basic) | Ch6 (expanded for public repo) | Entry point for contributors | + +### Secondary Files (appear 2-3 chapters) + +| Artifact | Chapters | Purpose | +|----------|----------|---------| +| `icons/` directory | Ch5 (Priya creates), Ch7 (blame for color change), Ch10 (packfile performance) | Binary file handling, large asset management | +| `CONTRIBUTING.md` | Ch6 (created for open source), Ch8 (referenced in hooks) | Governance, standards | +| `CHANGELOG.md` | Ch5 (v1.0 release), Ch7 (rewriting history) | Release documentation | +| `typography.json` | Ch7 (selective staging), Ch8 (attributes config) | Second token file for staging/splitting scenarios | + +--- + +## Scene-by-Scene Storyline Mapping to Existing Recommendations + +### Chapter 1 — Discovery + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Add concrete scenario after line 8's designer mention | Nora's "final-v3-REAL" folder disaster — she loses a week of button iterations | +| CVCS = Figma shared file analogy | Nora compares her Figma workflow (centralized) to Git (distributed) | +| Three states = draft/ready/approved | Nora maps modified/staged/committed to her existing review process | +| Binary file support flag | Nora asks: "Can I version my Sketch files?" — honest answer about binary limitations | + +### Chapter 2 — Foundation + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| "Initializing a design system repository" | Nora runs `git init` in the `meadow-design-system` directory | +| Replace `.c` file examples | All examples use `design-tokens.json`, `components/button/button.md`, exported PNGs | +| `.gitignore` template for designers | Nora creates `.gitignore` excluding `.sketch~`, `*.figma_cache`, `node_modules/` | +| Commit message conventions | Nora writes: `Add initial color palette and button component` | +| Design token search in log | Nora uses `git log -S "primary-blue"` to find when she changed the brand color | +| Tags for releases | Nora tags the repo's first stable state: `git tag -a v0.1 -m "Initial token set and button component"` | + +### Chapter 3 — Exploration + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Branch as design variant | Sam creates `feature/dark-mode` to explore a dark palette without touching Nora's light theme | +| Hotfix interruption scenario | Sam is working on dark mode; urgent accessibility bug on `main` button contrast — creates `hotfix/button-contrast` | +| Merge conflict in token file | Both Nora and Sam edited `colors.json` — Nora updated `primary-blue`, Sam added `dark-bg`. They resolve together. | +| Branch naming conventions | Team establishes: `feature/`, `fix/`, `hotfix/`, `experiment/` | +| Rebasing as "replay on cleaner foundation" | Sam rebases dark mode onto main to pick up Nora's latest token structure | + +### Chapter 4 — Infrastructure + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Lead with hosted options | Nora evaluates GitHub vs. GitLab — picks GitHub for simplicity | +| SSH key setup with context | Sam struggles with SSH keys — Nora walks him through it, comparing `.pub` file to a "trusted device" | +| Branch protection | Nora enables `main` branch protection: PRs required, one approval needed | +| Role mapping | Nora = admin, Sam = write, stakeholders = read-only | + +### Chapter 5 — Collaboration + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Three-person coordination | Nora (tokens), Sam (components), Priya (icons) work in parallel on feature branches | +| Replace `lib/simplegit.rb` files | All file references: `design-tokens/colors.json`, `components/Button/`, `icons/navigation/` | +| Integration-manager workflow | Nora acts as integrator — reviews and merges Sam's and Priya's branches | +| Design system release cycle | Team releases Meadow v1.0: tag, archive, changelog | +| Email workflow → skip notice | "Meadow uses GitHub PRs, not email patches" | + +### Chapter 6 — Open Source + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Replace Arduino blink with design system PR | Marcus forks Meadow, creates `feature/tooltip-component`, adds SVG + token + docs, opens PR with screenshots | +| Expand image embedding for reviews | Marcus includes light/dark mode screenshots in his PR; Nora annotates with feedback | +| CONTRIBUTING.md for design projects | Nora writes guidelines: icon grid (24x24), token naming (`category-property-variant`), accessibility requirements | +| GitHub Pages for documentation | Team deploys component documentation to `meadow-design-system.github.io` | +| Async collaboration norms | Marcus is in a different timezone — PR review takes 24 hours; Nora leaves detailed written feedback | + +### Chapter 7 — Maturity + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Stashing scenario | Sam is halfway through new button states; production color bug reported; stashes work, fixes bug, pops stash | +| `git blame` for design files | Priya uses `git blame icons/navigation/home.svg` to find who changed the icon stroke width | +| Interactive staging | Nora's `design-tokens.json` has both color and typography updates; she stages only color changes for the current PR | +| Reset demystified | Sam accidentally commits to `main` instead of his feature branch — uses `git reset` to move the commit | +| Squashing messy history | Priya squashes "Add home icon" + "Fix home icon size" + "Adjust home icon padding" into clean "Add navigation home icon" | +| Submodules | The product app repo includes `meadow-design-system` as a submodule — Dev updates the pointer when v1.1 releases | + +### Chapter 8 — Customization + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| `.gitattributes` for binary files | Nora configures: `*.png binary`, `*.sketch binary`, `*.svg diff` | +| Commit message template | Team template: `[Component: Name] Description` — enforced by commit-msg hook | +| Pre-commit hook | Hook validates `design-tokens.json` is valid JSON before allowing commit | +| Image diffing | Nora sets up EXIF-based diffing so `git diff` shows metadata changes on PNG exports | +| Export-ignore | `.sketch` source files are versioned but excluded from release archives | + +### Chapter 9 — Migration + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| SVN design archive migration | The company's legacy brand assets (logos, illustrations) live in SVN. Nora migrates them into the Meadow repo. | +| Large binary file handling | Migration surfaces 200MB of PSDs — team decides to use Git LFS for files >10MB | +| Pre-import planning | Nora checks total size, identifies files for LFS, plans branch structure | + +### Chapter 10 — Mastery + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Reflog for data recovery | Sam runs `git reset --hard` on `main` by accident, losing three commits. Nora uses reflog to recover. | +| Objects as "fingerprints" | Nora explains to Sam: "Every version of every file gets a unique ID. Even if you delete a branch, the data is still there." | +| Packfiles and performance | Priya notices `git push` is slow — learns Git packs similar icon files together | +| References as labels | "Branches are just sticky notes pointing to commits — moving them doesn't destroy anything" | + +### Appendix A — Tooling + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Decision tree | Nora uses CLI, Sam prefers VS Code's Git panel, Priya uses GitHub Desktop for visual diffs of icons | +| VS Code for token workflows | Sam edits `design-tokens.json` with inline Git diff highlighting | + +### Appendix B — Integration + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Design tool internals | Priya wonders how Figma plugins could auto-commit exported assets — learns about Dulwich (Python Git library) | +| UX patterns for Git integration | Nora sketches a "version control panel" for a design tool prototype | + +### Appendix C — Reference + +| Revision Note Recommendation | Storyline Scene | +|------------------------------|-----------------| +| Workflow-based organization | Commands grouped by Meadow workflow: "Starting your day" (pull, status), "Making changes" (add, commit), "Sharing work" (push, PR), "Releasing" (tag, archive) | + +--- + +## Key Benefits of the Unified Storyline + +1. **Progressive complexity**: readers learn Git operations in the order they'd encounter them on a real project +2. **Emotional investment**: readers care about Nora's team and their product — mistakes feel relatable, not abstract +3. **Artifact familiarity**: by Chapter 5, `design-tokens.json` and `colors.json` are old friends — readers focus on the Git concept, not parsing new file names +4. **Natural motivation**: each chapter answers "why do I need this?" through the story's progression (branching because Sam joined, GitHub because they went public, hooks because they need quality gates) +5. **Character-driven scenarios**: Sam's sloppiness triggers stash/reset/recovery lessons; Priya's binary files trigger LFS/attributes lessons; Nora's leadership triggers governance/hooks/release lessons + +--- + +## Risks and Mitigations + +| Risk | Mitigation | +|------|------------| +| Storyline feels forced in reference chapters (App C) | Use storyline as organizational principle, not narrative prose | +| Readers skip chapters and miss context | Each chapter opens with a 2-line "Previously in Meadow" recap | +| Product choice alienates some readers | "Wellness app" is generic enough; swap product name without breaking any examples | +| Characters feel contrived | Keep characterization minimal — traits emerge from actions, not descriptions | +| Chapters 9-10 have low design relevance | Migration and internals are naturally "advanced" — storyline justifies why the team encounters them | + +--- + +## Implementation Priority + +| Priority | Action | Impact | +|----------|--------|--------| +| 1 | Lock character names and roles across all chapters | Consistency foundation | +| 2 | Define the `meadow-design-system` repo file structure used in examples | Artifact continuity | +| 3 | Rewrite Ch1-3 examples with storyline (highest reader volume) | First impression | +| 4 | Rewrite Ch5-6 collaboration examples (most design-relevant) | Core value proposition | +| 5 | Update Ch7-8 tool examples with established artifacts | Builds on familiarity | +| 6 | Adapt Ch4, Ch9-10, appendices last (lowest impact) | Completeness | From 1f4a3811e64f88ec1ecb1f376640ad315d952841 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sun, 29 Mar 2026 03:27:17 +0000 Subject: [PATCH 10/18] Add task document for storyline rewrite to AI prototyping product Documents the pivot from design system to an AI-powered rapid prototyping product that generates 5 options from a single sketch, covering the full product lifecycle. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/storyline-rewrite-task.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 00-notes/storyline-rewrite-task.md diff --git a/00-notes/storyline-rewrite-task.md b/00-notes/storyline-rewrite-task.md new file mode 100644 index 000000000..9215601dd --- /dev/null +++ b/00-notes/storyline-rewrite-task.md @@ -0,0 +1,29 @@ +# Task: Rewrite Storyline Analysis + +## Status: In Progress + +## What Changed +The original `storyline-analysis.md` proposed "Meadow" — a design system for a wellness app — as the unifying storyline across all chapters. **A design system is not a product.** The storyline needs to follow a real product through a real design and development lifecycle. + +## New Direction +Replace the design system storyline with an **AI-powered rapid prototyping product** that: +- Generates up to **5 design options in parallel** from a single sketch +- Covers the **full product lifecycle**: research, concept design, UI design, visual design, development, testing, launch, iteration +- Gives readers a product they can follow from idea through shipping + +## Why This Product +- **Rich design artifact variety**: research docs, personas, journey maps, wireframes, mockups, prototypes, icons, illustrations, motion specs, design tokens, and production assets +- **Parallel generation is inherently visual**: 5 options from 1 sketch naturally produces branching/merging scenarios (each option is a branch; the chosen direction merges to main) +- **AI component adds modern relevance**: model configs, training data references, prompt templates — files that are text-based and Git-friendly alongside binary design files +- **Full lifecycle coverage**: unlike a design system (which is infrastructure), a product has research phases, concept phases, user testing, pivots, launches, and post-launch iteration — each mapping to different Git workflows + +## Requirements for the Rewrite +1. Replace all "Meadow design system" references with the new product concept +2. Redefine the team to reflect product roles (researcher, concept designer, UI/visual designer, engineer) +3. Remap the chapter timeline to product lifecycle phases (research → concept → design → build → test → launch → scale) +4. Update all artifact continuity maps to reflect product files (research briefs, personas, wireframes, screen mockups, prototype configs, AI model params) +5. Update all scene-by-scene mappings to use product scenarios +6. Preserve the structural framework (problem statement, benefits, risks, implementation priority) + +## File to Update +`00-notes/storyline-analysis.md` From bf97d6b61a65875b23d4c814b05493f5e5e6e1a5 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Mon, 30 Mar 2026 12:55:33 +0000 Subject: [PATCH 11/18] Rewrite storyline around AI-powered rapid prototyping product MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace design system concept with "SketchSpark" — an AI tool that generates 5 UI options from a single sketch. Covers full product lifecycle: research, concept design, UI design, build, beta, launch. Product's parallel generation mirrors Git's branching model. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/storyline-analysis.md | 257 ++++++++++++++++++--------------- 1 file changed, 141 insertions(+), 116 deletions(-) diff --git a/00-notes/storyline-analysis.md b/00-notes/storyline-analysis.md index e960aeb34..cb63e31f1 100644 --- a/00-notes/storyline-analysis.md +++ b/00-notes/storyline-analysis.md @@ -12,200 +12,224 @@ A unified storyline solves all three problems. Readers follow one product, one t --- -## Proposed Storyline: "Meadow" — A Design System for a Wellness App +## Proposed Storyline: "SketchSpark" — AI-Powered Rapid Prototyping + +### The Product +SketchSpark is an AI-powered rapid prototyping application. A designer uploads or draws a rough sketch, and the system generates up to 5 polished UI options in parallel. The designer reviews, selects, and refines a direction — then iterates toward a shippable product. ### Why This Product -- A wellness/health app is visually rich (illustrations, icons, color palettes, typography) — maximizes design artifact variety -- Broad enough to require multiple component types (forms, cards, navigation, charts, onboarding flows) -- Relatable across industries — not tied to fintech, e-commerce, or gaming jargon -- Naturally involves accessibility concerns (contrast, screen readers, motion sensitivity) +- **Parallel generation mirrors Git branching**: 5 options from 1 sketch = 5 branches from 1 commit. The core metaphor is baked into the product itself. +- **Full design lifecycle**: research (user interviews, competitive analysis), concept design (sketches, information architecture), UI design (wireframes, mockups), visual design (high-fidelity screens, motion), development, testing, launch, iteration — every phase produces distinct artifacts that need version control. +- **Rich artifact variety**: research briefs, persona documents, journey maps, wireframes, AI model configuration files, prompt templates, training data manifests, screen mockups, icon sets, motion specs, design tokens, and production assets — a mix of text (Git-friendly) and binary (Git-challenged) files that naturally teaches both workflows. +- **AI component adds modern relevance**: model configs (`model-params.yaml`), prompt templates (`prompts/sketch-to-ui.txt`), and generation pipelines are text files that merge cleanly — contrasting with binary mockup files that don't. +- **Accessible domain**: every designer understands "sketch to prototype" — no industry-specific jargon required. ### The Team | Character | Role | Personality Trait | Introduced | |-----------|------|-------------------|------------| -| **Nora** | Lead Designer / Design System Owner | Methodical, sets standards | Ch1 | -| **Sam** | UI Designer (components) | Moves fast, sometimes forgets to commit cleanly | Ch2 | -| **Priya** | Visual Designer (illustrations, icons) | Works with large binary files | Ch3 | -| **Dev (the developer)** | Frontend Engineer | Bridge between design and code — consumes tokens | Ch5 | +| **Nora** | UX Lead / Product Owner | Methodical researcher, sets standards, writes the briefs | Ch1 | +| **Sam** | UI/Visual Designer | Fast mover, generates options quickly, sometimes commits messy | Ch2 | +| **Priya** | Concept Designer / Illustrator | Works with large binary files (sketches, illustrations, journey maps) | Ch3 | +| **Kai** | Frontend Engineer / ML Integration | Bridges design and code, maintains AI pipeline configs | Ch5 | -Four characters are enough to demonstrate solo work, pair collaboration, team coordination, and cross-functional handoff. Each has a trait that naturally triggers specific Git scenarios. +Each character's working style naturally triggers specific Git scenarios: +- **Nora's** research documents and briefs are text-heavy — perfect for diffs and merges +- **Sam's** speed creates stash/reset/amend situations — he commits too fast, forgets files, works on wrong branches +- **Priya's** illustrations and high-fidelity mockups are large binaries — triggers LFS, attributes, and binary merge challenges +- **Kai's** model configs and pipeline files are structured text — demonstrates cross-functional collaboration and submodules ### The Product Timeline -The storyline maps to a realistic product lifecycle. Each chapter picks up where the prior left off: - -| Chapter | Story Phase | What Happens | -|---------|-------------|--------------| -| **Ch1** | Discovery | Nora discovers version control after losing a week of work when her "final-v3-REAL" folder gets overwritten. She learns what Git is and installs it. | -| **Ch2** | Foundation | Nora creates the Meadow design system repo. Adds `design-tokens.json`, component documentation, and exported assets. Learns status, add, commit, diff, log. Her first `.gitignore` excludes `.sketch` temp files. | -| **Ch3** | Exploration | Sam joins. They use branches to explore a dark mode variant (`feature/dark-mode`) while Nora continues refining the light theme on `main`. Their first merge conflict: both edited `colors.json`. | -| **Ch4** | Infrastructure | The team picks GitHub to host the repo (not a bare server). Nora sets up branch protection so `main` requires a review before merge. | -| **Ch5** | Collaboration | Priya joins for an icon overhaul. Three designers coordinate: Nora on tokens, Sam on components, Priya on icons. They practice the integration-manager workflow. First design system release (`v1.0`). | -| **Ch6** | Open Source | Meadow's design system goes public on GitHub. An external contributor (Marcus) forks it and submits a PR adding a Tooltip component. Nora reviews, requests changes, merges. | -| **Ch7** | Maturity | The team handles real-world complexity: Sam stashes half-finished button states to fix a production color bug. Priya uses `git blame` to find when an icon color changed. Nora uses interactive rebase to clean up a messy token migration history. | -| **Ch8** | Customization | Nora configures `.gitattributes` for binary design files, sets up a commit message template (`[Component: X]`), and adds a pre-commit hook that validates token JSON syntax. | -| **Ch9** | Migration | The team migrates legacy brand assets from an SVN archive into the Git repo. They handle large binary files and history cleanup. | -| **Ch10** | Mastery | Sam accidentally force-resets `main`, losing recent commits. Nora uses reflog to recover. The chapter demystifies Git internals through the lens of "your work is never truly lost." | -| **App A** | Tooling | The team evaluates VS Code vs. GitHub Desktop vs. CLI for their workflow. Decision tree based on comfort level. | -| **App B** | Integration | The team considers how design tools (Figma plugins, token pipelines) integrate with Git under the hood. | -| **App C** | Reference | Quick-reference card organized by Meadow workflow phases, not command taxonomy. | +Each chapter picks up where the prior left off, following SketchSpark from idea to shipped product: + +| Chapter | Product Phase | What Happens | +|---------|---------------|--------------| +| **Ch1** | Research & Discovery | Nora loses a week of user research notes when her "interview-notes-FINAL-v3" folder gets overwritten by a sync conflict. She discovers Git. Installs it. Learns what version control means through the lens of protecting research artifacts. | +| **Ch2** | Concept Design | Nora creates the SketchSpark repo. Adds the product brief (`product-brief.md`), early wireframes, competitive analysis, and persona documents. Learns status, add, commit, diff, log. Creates `.gitignore` for design tool temp files. First tag: `v0.1-concept`. | +| **Ch3** | Parallel Exploration | Sam joins to explore UI directions. The core product idea — 5 options from 1 sketch — plays out in their workflow: Sam creates 3 branches (`option/card-layout`, `option/list-layout`, `option/canvas-freeform`) to explore different approaches to the results screen. Nora continues refining the input sketch flow on `main`. Their first merge conflict: both edited `user-flows.md`. | +| **Ch4** | Team Infrastructure | The team moves from local-only to GitHub. Nora sets up the org, branch protection (no direct pushes to `main`), and team roles. They evaluate hosting options — GitHub wins over self-hosted for a startup-stage product. | +| **Ch5** | Design & Build Sprint | Priya joins for illustration and high-fidelity mockups. Kai joins to build the AI generation pipeline. Four people coordinating: Nora on UX flows, Sam on UI screens, Priya on onboarding illustrations, Kai on model configs. Integration-manager workflow. First milestone release: `v0.5-alpha` — the sketch-to-options pipeline works end to end. | +| **Ch6** | Public Beta & Community | SketchSpark launches a public beta on GitHub. External contributor (Marcus) forks the repo and submits a PR improving the prompt template for better mobile layouts. Nora reviews with annotated screenshots, requests changes, merges. The team writes CONTRIBUTING.md with guidelines for prompt templates, asset specs, and accessibility requirements. | +| **Ch7** | Production Hardening | Real-world complexity hits: Sam stashes half-finished screen designs to hotfix a broken onboarding flow. Priya uses `git blame` to find when an illustration's color palette drifted from the brand guide. Nora uses interactive rebase to clean up a messy sprint of "fix layout" / "fix layout again" / "actually fix layout" commits. Kai's AI pipeline repo becomes a submodule. | +| **Ch8** | Process & Automation | Nora configures `.gitattributes` for Priya's binary illustration files, creates a commit message template (`[Phase: Component] Description`), and adds a pre-commit hook that validates `model-params.yaml` syntax and checks that prompt templates don't exceed token limits. | +| **Ch9** | Legacy Migration | The company acquires a competitor whose design assets live in SVN. The team migrates 3 years of mockups, illustrations, and research documents into the SketchSpark repo. They handle large binaries, history cleanup, and Git LFS setup. | +| **Ch10** | Scale & Recovery | Sam accidentally force-resets `main`, losing three days of work before a launch deadline. Nora uses reflog to recover every commit. The chapter demystifies Git internals through the lens of "your work is never truly lost" — critical when months of design research, illustrations, and AI configs are at stake. | +| **App A** | Tooling Choices | Each team member uses different tools: Nora uses CLI, Sam prefers VS Code's Git panel for visual diffs of screen designs, Priya uses GitHub Desktop for large file management, Kai uses JetBrains. Decision tree based on role and comfort. | +| **App B** | Tool Integration | Kai explains how SketchSpark's own AI pipeline uses libgit2 under the hood to version-control generated options. Priya explores how Figma plugins use Dulwich (Python) to auto-export assets to Git. | +| **App C** | Reference | Quick-reference card organized by SketchSpark workflow phases: "Starting research" (init, clone), "Daily design work" (branch, add, commit, status), "Reviewing options" (diff, log, show), "Shipping a release" (tag, merge, push). | --- ## Artifact Continuity Map -These artifacts appear and evolve across chapters, giving readers anchoring reference points: +These artifacts appear and evolve across chapters, giving readers anchoring reference points. ### Core Files (appear 5+ chapters) | Artifact | First Appears | Evolves Through | Purpose | |----------|---------------|-----------------|---------| -| `design-tokens.json` | Ch2 (created) | Ch3 (dark mode added), Ch5 (v1.0 release), Ch7 (migration cleanup), Ch8 (validation hook) | The primary "code-like" design file — mergeable, diffable, central to the system | -| `colors.json` (subset of tokens) | Ch2 (initial palette) | Ch3 (merge conflict), Ch5 (coordinated update), Ch7 (blame for change), Ch8 (diff config) | Most relatable file for designers — color values changing | -| `components/button/` | Ch2 (first component) | Ch3 (dark mode variant), Ch5 (Sam's work), Ch7 (stash scenario), Ch8 (commit template) | The universal UI component — every designer understands buttons | -| `.gitignore` | Ch2 (created) | Ch8 (expanded for design tools) | Practical file designers need immediately | -| `README.md` | Ch2 (basic) | Ch6 (expanded for public repo) | Entry point for contributors | +| `product-brief.md` | Ch2 (created) | Ch3 (updated with chosen direction), Ch5 (alpha scope), Ch6 (public beta scope), Ch8 (commit template references it) | The "source of truth" text file — mergeable, diffable, anchors every design decision | +| `user-flows.md` | Ch2 (initial sketch flow) | Ch3 (merge conflict — Nora and Sam both edited), Ch5 (expanded for full pipeline), Ch7 (blame to find when a flow changed) | Primary UX artifact — where merge conflicts feel real and relatable | +| `screens/results/` | Ch3 (3 layout options as branches) | Ch5 (Sam's production screens), Ch7 (stash scenario mid-redesign), Ch8 (commit template) | The heart of the product — where parallel options become parallel branches | +| `model-params.yaml` | Ch5 (Kai creates) | Ch7 (submodule), Ch8 (pre-commit validation hook), Ch10 (recovered via reflog) | Structured text config — demonstrates Git-friendly AI/ML files alongside binary design files | +| `.gitignore` | Ch2 (created) | Ch5 (expanded for build artifacts), Ch8 (expanded for design tools and model caches) | Practical file designers need immediately | ### Secondary Files (appear 2-3 chapters) | Artifact | Chapters | Purpose | |----------|----------|---------| -| `icons/` directory | Ch5 (Priya creates), Ch7 (blame for color change), Ch10 (packfile performance) | Binary file handling, large asset management | -| `CONTRIBUTING.md` | Ch6 (created for open source), Ch8 (referenced in hooks) | Governance, standards | -| `CHANGELOG.md` | Ch5 (v1.0 release), Ch7 (rewriting history) | Release documentation | -| `typography.json` | Ch7 (selective staging), Ch8 (attributes config) | Second token file for staging/splitting scenarios | +| `research/personas/` | Ch2 (Nora creates), Ch5 (referenced in sprint planning), Ch9 (migrated from legacy) | Text-heavy research artifacts — ideal for diffs | +| `research/competitive-analysis.md` | Ch2 (created), Ch6 (updated when going public) | Shows how research docs evolve alongside product | +| `illustrations/onboarding/` | Ch5 (Priya creates), Ch7 (blame for color drift), Ch10 (packfile performance with large PNGs) | Binary file handling — large asset management | +| `prompts/sketch-to-ui.txt` | Ch5 (Kai creates), Ch6 (Marcus improves via PR), Ch8 (token-limit validation hook) | AI prompt templates — text files that external contributors can improve | +| `CONTRIBUTING.md` | Ch6 (created for public beta), Ch8 (referenced in hooks) | Governance and standards for open contribution | +| `CHANGELOG.md` | Ch5 (v0.5-alpha), Ch7 (rewriting history to clean up entries) | Release documentation | +| `design-tokens.json` | Ch5 (Sam creates for handoff to Kai), Ch7 (selective staging — color vs. typography), Ch8 (attributes config) | Bridge between design and code — the handoff file | + +### Lifecycle Phase Artifacts + +| Product Phase | Key Artifacts | File Types | Git Behavior | +|---------------|---------------|------------|--------------| +| Research | `product-brief.md`, `personas/*.md`, `competitive-analysis.md`, `interview-notes/*.md` | Markdown, text | Fully mergeable, excellent diffs | +| Concept Design | `user-flows.md`, `information-architecture.md`, `sketches/*.png` | Mixed | Text merges cleanly; sketch PNGs are binary | +| UI Design | `screens/**/*.fig`, `screens/**/*.png`, `wireframes/*.md` | Mostly binary | Binary conflicts require manual resolution | +| Visual Design | `illustrations/**/*.png`, `icons/**/*.svg`, `design-tokens.json` | Binary + JSON | SVGs diff as text; PNGs don't; tokens merge | +| AI Pipeline | `model-params.yaml`, `prompts/*.txt`, `training-data-manifest.json` | Structured text | Fully mergeable, hookable, validatable | +| Production | `assets/exported/**`, `docs/`, `CHANGELOG.md` | Mixed | Export-ignore for source files; archive for releases | --- ## Scene-by-Scene Storyline Mapping to Existing Recommendations -### Chapter 1 — Discovery +### Chapter 1 — Research & Discovery | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Add concrete scenario after line 8's designer mention | Nora's "final-v3-REAL" folder disaster — she loses a week of button iterations | -| CVCS = Figma shared file analogy | Nora compares her Figma workflow (centralized) to Git (distributed) | -| Three states = draft/ready/approved | Nora maps modified/staged/committed to her existing review process | -| Binary file support flag | Nora asks: "Can I version my Sketch files?" — honest answer about binary limitations | +| Add concrete scenario after line 8's designer mention | Nora's "interview-notes-FINAL-v3" folder disaster — a cloud sync conflict overwrites a week of user research for the SketchSpark concept | +| CVCS = Figma shared file analogy | Nora compares her team's shared Google Drive (centralized, single point of failure) to Git (full local copy of all research history) | +| Three states = draft/ready/approved | Nora maps modified/staged/committed to her research workflow: draft notes → reviewed findings → published insight | +| Binary file support flag | Nora asks: "Can I version my sketch mockups and interview recordings?" — honest answer about binary limitations sets up a theme that runs through every chapter | -### Chapter 2 — Foundation +### Chapter 2 — Concept Design | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| "Initializing a design system repository" | Nora runs `git init` in the `meadow-design-system` directory | -| Replace `.c` file examples | All examples use `design-tokens.json`, `components/button/button.md`, exported PNGs | -| `.gitignore` template for designers | Nora creates `.gitignore` excluding `.sketch~`, `*.figma_cache`, `node_modules/` | -| Commit message conventions | Nora writes: `Add initial color palette and button component` | -| Design token search in log | Nora uses `git log -S "primary-blue"` to find when she changed the brand color | -| Tags for releases | Nora tags the repo's first stable state: `git tag -a v0.1 -m "Initial token set and button component"` | +| "Initializing a design system repository" | Nora runs `git init` in the `sketchspark/` directory after completing the concept phase | +| Replace `.c` file examples | All examples use `product-brief.md`, `research/personas/early-adopter.md`, `wireframes/sketch-input-flow.png` | +| `.gitignore` template for designers | Nora creates `.gitignore` excluding `.sketch~`, `*.figma_cache`, `__MACOSX/`, `.DS_Store`, `node_modules/` | +| Commit message conventions | Nora writes: `Add product brief and initial user flow wireframes` | +| Design token search in log | Nora uses `git log -S "single sketch"` to find when the core product concept changed from "3 options" to "5 options" in the brief | +| Tags for releases | Nora tags the concept milestone: `git tag -a v0.1-concept -m "Research complete, concept approved, entering UI exploration"` | -### Chapter 3 — Exploration +### Chapter 3 — Parallel Exploration | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Branch as design variant | Sam creates `feature/dark-mode` to explore a dark palette without touching Nora's light theme | -| Hotfix interruption scenario | Sam is working on dark mode; urgent accessibility bug on `main` button contrast — creates `hotfix/button-contrast` | -| Merge conflict in token file | Both Nora and Sam edited `colors.json` — Nora updated `primary-blue`, Sam added `dark-bg`. They resolve together. | -| Branch naming conventions | Team establishes: `feature/`, `fix/`, `hotfix/`, `experiment/` | -| Rebasing as "replay on cleaner foundation" | Sam rebases dark mode onto main to pick up Nora's latest token structure | +| Branch as design variant | Sam creates `option/card-layout`, `option/list-layout`, `option/canvas-freeform` — three parallel UI directions for the results screen, mirroring SketchSpark's own "5 options from 1 sketch" philosophy | +| Hotfix interruption scenario | Sam is deep in `option/card-layout`; Nora discovers a critical user flow gap in the sketch input screen on `main` — Sam creates `fix/sketch-input-upload-error` | +| Merge conflict in token file | Both Nora and Sam edited `user-flows.md` — Nora refined the upload step, Sam added a "compare options" step. They resolve together, learning that text files merge but require coordination. | +| Branch naming conventions | Team establishes: `option/` (design explorations), `feature/` (approved work), `fix/` (corrections), `research/` (investigation branches) | +| Rebasing as "replay on cleaner foundation" | Sam rebases `option/card-layout` onto main to pick up Nora's updated user flow before the team reviews all three options side by side | -### Chapter 4 — Infrastructure +### Chapter 4 — Team Infrastructure | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Lead with hosted options | Nora evaluates GitHub vs. GitLab — picks GitHub for simplicity | -| SSH key setup with context | Sam struggles with SSH keys — Nora walks him through it, comparing `.pub` file to a "trusted device" | -| Branch protection | Nora enables `main` branch protection: PRs required, one approval needed | -| Role mapping | Nora = admin, Sam = write, stakeholders = read-only | +| Lead with hosted options | Nora evaluates GitHub vs. GitLab for the growing team — picks GitHub for its PR review workflow and project boards | +| SSH key setup with context | Sam struggles with SSH keys — Nora walks him through it: "The `.pub` file is like a badge that proves who you are. The private file is your ID — never share it." | +| Branch protection | Nora enables `main` branch protection: PRs required, one design review approval needed before merge. No direct commits to `main`. | +| Role mapping | Nora = admin (merges to main, manages releases), Sam = write (creates branches, opens PRs), stakeholders = read-only (view progress, leave comments) | -### Chapter 5 — Collaboration +### Chapter 5 — Design & Build Sprint | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Three-person coordination | Nora (tokens), Sam (components), Priya (icons) work in parallel on feature branches | -| Replace `lib/simplegit.rb` files | All file references: `design-tokens/colors.json`, `components/Button/`, `icons/navigation/` | -| Integration-manager workflow | Nora acts as integrator — reviews and merges Sam's and Priya's branches | -| Design system release cycle | Team releases Meadow v1.0: tag, archive, changelog | -| Email workflow → skip notice | "Meadow uses GitHub PRs, not email patches" | +| Three-person coordination | Nora (UX flows and research updates), Sam (production UI screens), Priya (onboarding illustrations), Kai (AI pipeline configs) — four parallel workstreams | +| Replace `lib/simplegit.rb` files | All file references: `screens/results/card-layout.fig`, `illustrations/onboarding/step-1.png`, `model-params.yaml`, `prompts/sketch-to-ui.txt` | +| Integration-manager workflow | Nora acts as integrator — reviews Sam's screen PRs, Priya's illustration PRs, and Kai's pipeline PRs before merging to `main` | +| Design system release cycle | Team releases SketchSpark `v0.5-alpha`: the sketch-to-options pipeline works end to end. Tag, archive, changelog. Sam creates `design-tokens.json` for handoff to Kai's frontend. | +| Email workflow → skip notice | "The SketchSpark team uses GitHub PRs for all collaboration. Email-based patches are a legacy workflow — skip unless contributing to projects that require them." | -### Chapter 6 — Open Source +### Chapter 6 — Public Beta & Community | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Replace Arduino blink with design system PR | Marcus forks Meadow, creates `feature/tooltip-component`, adds SVG + token + docs, opens PR with screenshots | -| Expand image embedding for reviews | Marcus includes light/dark mode screenshots in his PR; Nora annotates with feedback | -| CONTRIBUTING.md for design projects | Nora writes guidelines: icon grid (24x24), token naming (`category-property-variant`), accessibility requirements | -| GitHub Pages for documentation | Team deploys component documentation to `meadow-design-system.github.io` | -| Async collaboration norms | Marcus is in a different timezone — PR review takes 24 hours; Nora leaves detailed written feedback | +| Replace Arduino blink with design system PR | Marcus forks SketchSpark, creates `feature/mobile-prompt-template`, improves `prompts/sketch-to-ui.txt` for better mobile layout generation, opens PR with before/after screenshots of generated options | +| Expand image embedding for reviews | Marcus includes side-by-side screenshots: "Current mobile output" vs. "Improved mobile output" with 5 generated options each. Nora annotates with feedback directly in the PR. | +| CONTRIBUTING.md for design projects | Nora writes guidelines: prompt template format, illustration specs (2x resolution, brand palette), screen mockup naming conventions, accessibility requirements for generated UI | +| GitHub Pages for documentation | Team deploys SketchSpark user docs and API reference to `sketchspark.github.io` | +| Async collaboration norms | Marcus is in a different timezone — PR review takes 24 hours. Nora leaves detailed written feedback with annotated screenshots rather than expecting a synchronous call. | -### Chapter 7 — Maturity +### Chapter 7 — Production Hardening | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Stashing scenario | Sam is halfway through new button states; production color bug reported; stashes work, fixes bug, pops stash | -| `git blame` for design files | Priya uses `git blame icons/navigation/home.svg` to find who changed the icon stroke width | -| Interactive staging | Nora's `design-tokens.json` has both color and typography updates; she stages only color changes for the current PR | -| Reset demystified | Sam accidentally commits to `main` instead of his feature branch — uses `git reset` to move the commit | -| Squashing messy history | Priya squashes "Add home icon" + "Fix home icon size" + "Adjust home icon padding" into clean "Add navigation home icon" | -| Submodules | The product app repo includes `meadow-design-system` as a submodule — Dev updates the pointer when v1.1 releases | +| Stashing scenario | Sam is redesigning the results comparison screen; urgent bug report — the onboarding flow crashes on tablet. Sam stashes his half-finished screens, switches to `fix/onboarding-tablet`, fixes the layout, merges, pops his stash, and continues. | +| `git blame` for design files | Priya uses `git blame illustrations/onboarding/step-2.png` to find who changed the illustration's color palette — it drifted from the brand guide three commits ago during a rushed sprint. | +| Interactive staging | Nora's `product-brief.md` has both a scope change (adding tablet support) and a research update (new user interview findings). She stages only the research update for the current PR, saving the scope change for a separate review. | +| Reset demystified | Sam accidentally commits directly to `main` instead of his feature branch — uses `git reset --soft HEAD~1` to move the commit back to staging, then creates the correct branch. | +| Squashing messy history | Sam squashes "Update results layout" + "Fix results layout spacing" + "Actually fix the spacing this time" + "Tweak padding" into clean "Redesign results comparison screen for card layout" | +| Submodules | Kai's AI pipeline repo (`sketchspark-ml`) becomes a submodule of the main product repo. When the model improves option generation quality, Kai updates the submodule pointer and the team pulls the new version. | -### Chapter 8 — Customization +### Chapter 8 — Process & Automation | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| `.gitattributes` for binary files | Nora configures: `*.png binary`, `*.sketch binary`, `*.svg diff` | -| Commit message template | Team template: `[Component: Name] Description` — enforced by commit-msg hook | -| Pre-commit hook | Hook validates `design-tokens.json` is valid JSON before allowing commit | -| Image diffing | Nora sets up EXIF-based diffing so `git diff` shows metadata changes on PNG exports | -| Export-ignore | `.sketch` source files are versioned but excluded from release archives | +| `.gitattributes` for binary files | Nora configures: `*.png binary`, `*.fig binary`, `*.svg diff`, `*.md diff`, `*.yaml diff` — so Git knows which files can be meaningfully diffed | +| Commit message template | Team template enforced by hook: `[Phase: Component] Description` — e.g., `[Design: Results Screen] Add tablet breakpoint layout` or `[Research: Persona] Update early-adopter goals after round 2 interviews` | +| Pre-commit hook | Hook validates that `model-params.yaml` is valid YAML, checks that prompt templates in `prompts/` don't exceed 4096 tokens, and warns if PNG files exceed 5MB | +| Image diffing | Nora sets up EXIF-based diffing so `git diff` shows metadata changes on exported screen mockups — dimensions, color profile, export date | +| Export-ignore | `.fig` source files and `research/raw-interviews/` are versioned in Git but excluded from release archives via `.gitattributes export-ignore` | -### Chapter 9 — Migration +### Chapter 9 — Legacy Migration | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| SVN design archive migration | The company's legacy brand assets (logos, illustrations) live in SVN. Nora migrates them into the Meadow repo. | -| Large binary file handling | Migration surfaces 200MB of PSDs — team decides to use Git LFS for files >10MB | -| Pre-import planning | Nora checks total size, identifies files for LFS, plans branch structure | +| SVN design archive migration | SketchSpark acquires a competitor ("QuickMock") whose 3 years of mockups, user research, and design assets live in SVN. Nora leads the migration into the SketchSpark repo. | +| Large binary file handling | Migration surfaces 400MB of PSD source files and high-res mockups — team configures Git LFS for files >10MB | +| Pre-import planning | Nora audits total size, identifies files for LFS, maps QuickMock's flat folder structure to SketchSpark's organized directory hierarchy, and plans which history to preserve vs. squash | -### Chapter 10 — Mastery +### Chapter 10 — Scale & Recovery | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Reflog for data recovery | Sam runs `git reset --hard` on `main` by accident, losing three commits. Nora uses reflog to recover. | -| Objects as "fingerprints" | Nora explains to Sam: "Every version of every file gets a unique ID. Even if you delete a branch, the data is still there." | -| Packfiles and performance | Priya notices `git push` is slow — learns Git packs similar icon files together | -| References as labels | "Branches are just sticky notes pointing to commits — moving them doesn't destroy anything" | +| Reflog for data recovery | Two days before the v1.0 launch, Sam runs `git reset --hard` on `main` by accident, losing three days of final polish commits. Nora uses `git reflog` to find the lost HEAD, creates a recovery branch, and restores everything. | +| Objects as "fingerprints" | Nora explains to Sam: "Every version of every file — every screen mockup, every prompt template, every research note — gets a unique ID. Even if you delete a branch, the data is still in Git's object store." | +| Packfiles and performance | Priya notices `git push` takes 90 seconds — learns that Git packs similar illustration files together using delta compression, but her 50MB PSD additions bypass efficient packing. The team moves large files to LFS. | +| References as labels | "Branches are just labels pointing to commits — like sticky notes on a timeline. Moving them doesn't destroy anything. That's why Sam's 'lost' work was still there." | -### Appendix A — Tooling +### Appendix A — Tooling Choices | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Decision tree | Nora uses CLI, Sam prefers VS Code's Git panel, Priya uses GitHub Desktop for visual diffs of icons | -| VS Code for token workflows | Sam edits `design-tokens.json` with inline Git diff highlighting | +| Decision tree | Nora uses CLI (fastest for research doc workflows), Sam prefers VS Code's Git panel (inline diffs of screen designs and tokens), Priya uses GitHub Desktop (visual staging of large illustration files), Kai uses JetBrains (integrated with Python ML pipeline) | +| VS Code for token workflows | Sam edits `design-tokens.json` and `user-flows.md` with inline Git gutter indicators showing what changed since last commit | -### Appendix B — Integration +### Appendix B — Tool Integration | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Design tool internals | Priya wonders how Figma plugins could auto-commit exported assets — learns about Dulwich (Python Git library) | -| UX patterns for Git integration | Nora sketches a "version control panel" for a design tool prototype | +| Design tool internals | Kai explains how SketchSpark's own generation pipeline uses libgit2 to version-control each of the 5 generated options as lightweight branches — the product's architecture mirrors Git's branching model | +| UX patterns for Git integration | Nora designs SketchSpark's "version history" panel — translating Git concepts (commits, branches, diffs) into a visual interface that non-technical designers can use | +| Dulwich / Python integration | Priya's export script uses Dulwich to auto-commit illustration assets to Git whenever she exports from her design tool — removing manual `git add` from her workflow | ### Appendix C — Reference | Revision Note Recommendation | Storyline Scene | |------------------------------|-----------------| -| Workflow-based organization | Commands grouped by Meadow workflow: "Starting your day" (pull, status), "Making changes" (add, commit), "Sharing work" (push, PR), "Releasing" (tag, archive) | +| Workflow-based organization | Commands grouped by SketchSpark workflow: "Starting a research phase" (init, clone, branch), "Daily design work" (status, add, commit, diff), "Reviewing options" (log, show, diff between branches), "Collaborating" (push, pull, fetch, merge), "Shipping a release" (tag, archive, merge to main) | --- ## Key Benefits of the Unified Storyline -1. **Progressive complexity**: readers learn Git operations in the order they'd encounter them on a real project -2. **Emotional investment**: readers care about Nora's team and their product — mistakes feel relatable, not abstract -3. **Artifact familiarity**: by Chapter 5, `design-tokens.json` and `colors.json` are old friends — readers focus on the Git concept, not parsing new file names -4. **Natural motivation**: each chapter answers "why do I need this?" through the story's progression (branching because Sam joined, GitHub because they went public, hooks because they need quality gates) -5. **Character-driven scenarios**: Sam's sloppiness triggers stash/reset/recovery lessons; Priya's binary files trigger LFS/attributes lessons; Nora's leadership triggers governance/hooks/release lessons +1. **Progressive complexity**: readers learn Git operations in the order they'd encounter them building a real product — research notes before merge conflicts, branching before rebasing +2. **Product mirrors Git**: SketchSpark generates 5 parallel options from 1 sketch; Git creates parallel branches from 1 commit. The product's core concept reinforces the most important Git mental model. +3. **Artifact familiarity**: by Chapter 5, `product-brief.md`, `user-flows.md`, and `screens/results/` are familiar landmarks — readers focus on the Git concept, not parsing new file names +4. **Full lifecycle coverage**: research, concept, design, build, test, launch, scale — every phase produces different artifacts (text vs. binary, solo vs. collaborative) that naturally teach different Git workflows +5. **Natural motivation**: each chapter answers "why do I need this?" through the product's progression — branching because the team explores 3 UI options, GitHub because they launched a beta, hooks because they need quality gates before shipping +6. **Character-driven scenarios**: Sam's speed creates stash/reset/recovery lessons; Priya's binary files trigger LFS/attributes lessons; Nora's leadership triggers governance/review/release lessons; Kai's ML pipeline triggers submodule/cross-functional lessons --- @@ -214,10 +238,11 @@ These artifacts appear and evolve across chapters, giving readers anchoring refe | Risk | Mitigation | |------|------------| | Storyline feels forced in reference chapters (App C) | Use storyline as organizational principle, not narrative prose | -| Readers skip chapters and miss context | Each chapter opens with a 2-line "Previously in Meadow" recap | -| Product choice alienates some readers | "Wellness app" is generic enough; swap product name without breaking any examples | -| Characters feel contrived | Keep characterization minimal — traits emerge from actions, not descriptions | -| Chapters 9-10 have low design relevance | Migration and internals are naturally "advanced" — storyline justifies why the team encounters them | +| Readers skip chapters and miss context | Each chapter opens with a 2-line "Previously on SketchSpark" recap | +| AI product concept feels niche | The design workflow (research → concept → UI → ship) is universal; the AI generation is flavor, not prerequisite | +| Characters feel contrived | Keep characterization minimal — traits emerge from actions (Sam's messy commits, Priya's large files), not backstory | +| Chapters 9-10 have lower design relevance | Migration and internals are naturally "advanced" — the storyline (acquiring a competitor, recovering before launch) justifies why the team encounters them | +| Binary file challenges recur without resolution | Thread Git LFS as a progressive solution: mentioned Ch1, explained Ch5, configured Ch8, essential in Ch9 | --- @@ -225,9 +250,9 @@ These artifacts appear and evolve across chapters, giving readers anchoring refe | Priority | Action | Impact | |----------|--------|--------| -| 1 | Lock character names and roles across all chapters | Consistency foundation | -| 2 | Define the `meadow-design-system` repo file structure used in examples | Artifact continuity | -| 3 | Rewrite Ch1-3 examples with storyline (highest reader volume) | First impression | -| 4 | Rewrite Ch5-6 collaboration examples (most design-relevant) | Core value proposition | -| 5 | Update Ch7-8 tool examples with established artifacts | Builds on familiarity | -| 6 | Adapt Ch4, Ch9-10, appendices last (lowest impact) | Completeness | +| 1 | Lock character names, roles, and traits across all chapters | Consistency foundation | +| 2 | Define the `sketchspark/` repo file structure used in examples | Artifact continuity | +| 3 | Rewrite Ch1-3 examples with storyline (highest reader volume, establishes the product) | First impression — readers decide here whether to continue | +| 4 | Rewrite Ch5-6 collaboration examples (most design-relevant, introduces full team) | Core value proposition — collaboration is why designers need Git | +| 5 | Update Ch7-8 tool examples with established artifacts and characters | Builds on familiarity — advanced tools feel less intimidating | +| 6 | Adapt Ch4, Ch9-10, appendices last (infrastructure and advanced topics) | Completeness — important but lower reader volume | From d0ee6b6e9af61974f80874cbbc00e0e10b591117 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Tue, 31 Mar 2026 15:55:12 +0000 Subject: [PATCH 12/18] Add complete SketchSpark storyline for UX designer edition Self-contained narrative following an AI-powered rapid prototyping product from research through launch. Covers all 10 chapters and 3 appendices with consistent characters, artifacts, and themes. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/storyline.md | 682 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 682 insertions(+) create mode 100644 00-notes/storyline.md diff --git a/00-notes/storyline.md b/00-notes/storyline.md new file mode 100644 index 000000000..23215cf51 --- /dev/null +++ b/00-notes/storyline.md @@ -0,0 +1,682 @@ +# The SketchSpark Storyline + +## The Product + +**SketchSpark** is an AI-powered rapid prototyping application. A designer uploads or draws a rough sketch — a napkin wireframe, a whiteboard photo, a tablet drawing — and SketchSpark generates up to five polished UI options in parallel. The designer reviews, compares, selects a direction, refines it, and iterates toward a shippable product. + +The product serves a gap in the design-to-development pipeline: the jump from rough idea to testable prototype is slow. SketchSpark collapses it from days to minutes. + +--- + +## The Team + +**Nora** — UX Lead and Product Owner. She came from agency work where she managed design research across dozens of client projects, all versioned as "final_v3_REAL_USE-THIS.pdf" on shared drives. She's methodical, writes thorough briefs, and sets process standards. She's the one who brings Git to the team after a catastrophic file loss. She uses the CLI. + +**Sam** — UI and Visual Designer. He's fast. He generates screen layouts the way a jazz musician improvises — quickly, instinctively, and sometimes messily. He commits too often with vague messages, works on the wrong branch, and forgets to pull before pushing. Every Git mistake a designer can make, Sam makes first. He uses VS Code. + +**Priya** — Concept Designer and Illustrator. She creates the product's visual identity: onboarding illustrations, marketing assets, icon sets, and high-fidelity mockups. Her files are large — 30MB PSDs, layered Sketch files, high-resolution PNGs. She's the team member who stress-tests Git's handling of binary files. She uses GitHub Desktop. + +**Kai** — Frontend Engineer and ML Integration Lead. He joins when the product moves from concept to build. He maintains the AI generation pipeline: model parameters, prompt templates, training data manifests. His files are structured text (YAML, JSON, plain text) that merge cleanly — the opposite of Priya's binaries. He bridges design and engineering. He uses JetBrains. + +**Marcus** — External Contributor. He appears in Chapter 6 when SketchSpark goes public beta. He's a designer in another timezone who forks the repo, improves a prompt template for mobile layouts, and submits a pull request. He represents the open-source contribution experience. + +--- + +## The Repository + +``` +sketchspark/ +├── product-brief.md # The source of truth — what are we building and why +├── research/ +│ ├── personas/ +│ │ ├── early-adopter.md # Primary persona: freelance UI designer +│ │ └── team-lead.md # Secondary persona: design team manager +│ ├── competitive-analysis.md # Landscape of existing prototyping tools +│ ├── interview-notes/ +│ │ ├── round-1-findings.md # Initial discovery interviews +│ │ └── round-2-findings.md # Post-alpha validation interviews +│ └── journey-maps/ +│ └── sketch-to-prototype.png # Current-state journey map (binary) +├── concept/ +│ ├── information-architecture.md # App structure and navigation model +│ ├── user-flows.md # Step-by-step task flows +│ └── wireframes/ +│ ├── sketch-input.png # Upload/draw screen (binary) +│ └── results-comparison.png # Side-by-side options screen (binary) +├── screens/ +│ ├── onboarding/ +│ │ ├── welcome.fig # Figma source (binary, large) +│ │ └── welcome.png # Exported preview +│ ├── sketch-input/ +│ │ ├── upload-flow.fig +│ │ └── upload-flow.png +│ └── results/ +│ ├── card-layout.fig +│ ├── card-layout.png +│ ├── list-layout.fig +│ ├── list-layout.png +│ ├── canvas-freeform.fig +│ └── canvas-freeform.png +├── illustrations/ +│ ├── onboarding/ +│ │ ├── step-1-upload.png # Large illustrated graphics (binary) +│ │ ├── step-2-generate.png +│ │ └── step-3-refine.png +│ └── marketing/ +│ └── hero-image.psd # Very large source file (binary, LFS) +├── icons/ +│ ├── navigation/ +│ │ ├── home.svg # SVG diffs as text +│ │ ├── settings.svg +│ │ └── history.svg +│ └── actions/ +│ ├── upload.svg +│ ├── generate.svg +│ └── compare.svg +├── design-tokens.json # Colors, typography, spacing — handoff to engineering +├── pipeline/ # AI generation pipeline (Kai's domain) +│ ├── model-params.yaml # Model configuration +│ ├── prompts/ +│ │ ├── sketch-to-ui.txt # Core generation prompt +│ │ ├── mobile-layout.txt # Mobile-specific prompt +│ │ └── accessibility-check.txt # Post-generation a11y validation prompt +│ └── training-data-manifest.json # References to training datasets +├── docs/ +│ ├── setup-guide.md +│ └── api-reference.md +├── CONTRIBUTING.md +├── CHANGELOG.md +├── .gitignore +└── .gitattributes +``` + +This structure ensures every chapter has realistic files to reference. Research artifacts are text-heavy (merge-friendly). Screen mockups and illustrations are binary (merge-hostile). Pipeline configs are structured text (hookable, validatable). The variety is intentional — it teaches Git's strengths and limitations simultaneously. + +--- + +## Chapter 1 — Research & Discovery + +Nora is a UX lead at a small startup. She's been running user research for a new product idea — an AI tool that turns rough sketches into polished prototypes. She has three weeks of interview notes, a competitive analysis, two persona documents, and a journey map. They live in a folder on her laptop called `sketchspark-research/`. + +One morning, her cloud sync overwrites the folder with a week-old version. Her latest interview findings, the revised competitive analysis, and the updated journey map are gone. She spends two days reconstructing what she can from memory and Slack messages. She never fully recovers the competitive analysis. + +A developer friend tells her: "This is exactly what Git solves." + +Nora installs Git. She learns what version control is — not through the history of Linux and BitKeeper, but through the pain of losing irreplaceable research. She learns that **centralized version control** is like her shared Google Drive: everyone connects to one place, and if it goes down or conflicts, work is lost. **Distributed version control** means every team member has the full history locally. If the cloud disappears tomorrow, her laptop still has everything. + +She learns the three states — modified, staged, committed — and maps them to her own workflow: +- **Modified**: she's updated the interview notes but hasn't marked them as ready +- **Staged**: she's selected which updates to bundle into a checkpoint +- **Committed**: the checkpoint is permanent — she can always come back to it + +She sets up her identity (`git config`) so her name appears on every checkpoint she creates. She asks: "Can I version my journey map PNGs and Sketch files?" The honest answer: Git handles them, but it can't show you what changed inside them the way it can with text. This limitation — binary vs. text — becomes a thread that runs through every chapter. + +--- + +## Chapter 2 — Concept Design + +Nora creates the SketchSpark repository. + +``` +cd sketchspark +git init +``` + +She adds the product brief, her persona documents, the competitive analysis, and the initial user flow. Each one is a markdown file — Git can track every word that changes. + +``` +git add product-brief.md research/personas/ research/competitive-analysis.md concept/user-flows.md +git commit -m "Add product brief, personas, competitive analysis, and initial user flows" +``` + +She learns the daily rhythm: check status, stage changes, write a commit message that explains *why* (not just *what*), review the log to see her project's history. She creates a `.gitignore` to exclude temp files her design tools generate: + +``` +.DS_Store +__MACOSX/ +*.sketch~ +*.figma_cache +Thumbs.db +``` + +She adds wireframe exports — PNGs of the sketch input screen and the results comparison screen. These are binary files. Git accepts them, but `git diff` shows nothing useful. She notes this and keeps going. + +She commits the wireframes separately from the text files — a habit she develops because text and binary changes serve different review purposes: + +``` +git add concept/wireframes/ +git commit -m "Add wireframes for sketch input and results comparison screens" +``` + +She explores the log. She uses `git log -S "5 options"` to find when she changed the product brief from "3 options" to "5 options" — tracing a design decision through history. + +She tags the milestone: + +``` +git tag -a v0.1-concept -m "Research complete, concept approved, entering UI exploration" +``` + +The concept phase is over. The product has a brief, personas, a competitive landscape, user flows, and wireframes — all versioned, all recoverable. + +--- + +## Chapter 3 — Parallel Exploration + +Sam joins the project. He's a UI designer who works fast. Nora brings him up to speed on the product brief and user flows, then asks him to explore layout directions for the results screen — the screen where users see their 5 generated options side by side. + +Sam's assignment mirrors the product itself: generate multiple options in parallel, then choose the best direction. + +He creates three branches: + +``` +git checkout -b option/card-layout +git checkout -b option/list-layout +git checkout -b option/canvas-freeform +``` + +Each branch contains a different approach to the same screen. On `option/card-layout`, the 5 options appear as cards in a grid. On `option/list-layout`, they stack vertically with detail panels. On `option/canvas-freeform`, they float on an infinite canvas the user can pan and zoom. + +While Sam explores, Nora continues refining the sketch input flow on `main`. She updates `concept/user-flows.md` to clarify the upload step. + +Sam, on `option/card-layout`, also edits `concept/user-flows.md` — he adds a "compare options" step that doesn't exist yet. Neither knows the other has touched the same file. + +Sam finishes the card layout and switches back to main: + +``` +git checkout main +git merge option/card-layout +``` + +**Conflict.** Both edited `concept/user-flows.md`. Git can't automatically reconcile Nora's upload clarification with Sam's new comparison step. They sit together, open the file, and see Git's conflict markers. They keep both changes — Nora's refined upload step *and* Sam's comparison step — in the right order. They commit the resolution. + +This is the team's first merge conflict. It's a text file, so the markers make sense. Nora notes: "If this had been a Figma file or a PSD, Git couldn't show us the conflict at all. We'd have to open both versions and manually compare." + +They establish branch naming conventions: +- `option/` — design explorations (may be discarded) +- `feature/` — approved work heading to production +- `fix/` — corrections to existing work +- `research/` — investigation branches (new interviews, usability tests) + +Mid-exploration, Nora discovers a critical flaw in the sketch input screen on `main` — the upload error state is missing. Sam is deep in `option/list-layout`. He creates a hotfix: + +``` +git stash +git checkout main +git checkout -b fix/sketch-input-upload-error +``` + +He designs the error state, commits, merges to main, then returns to his exploration: + +``` +git checkout option/list-layout +git stash pop +``` + +The team reviews all three options. They choose the card layout. Sam rebases the other two branches onto the latest main (which now includes the card layout merge) to see if any ideas from `list-layout` or `canvas-freeform` are worth carrying forward. They cherry-pick the "pinch-to-zoom on selected option" interaction from `canvas-freeform` into a new `feature/zoom-on-selection` branch. + +The exploration phase ends. One direction chosen, two archived, one idea salvaged. + +--- + +## Chapter 4 — Team Infrastructure + +The project has outgrown Nora's laptop. Sam needs access. They're about to bring on an illustrator. The repo needs a home. + +Nora evaluates options. Self-hosted Git servers are overkill for a three-person startup. GitHub offers pull request reviews, branch protection, project boards, and free private repos. GitLab has similar features but the team already has GitHub accounts. They go with GitHub. + +Nora creates the `sketchspark` organization and pushes the repo: + +``` +git remote add origin git@github.com:sketchspark/sketchspark.git +git push -u origin main +``` + +Sam needs SSH access. Nora walks him through key generation: "The `.pub` file is a badge — you give it to GitHub to prove who you are. The other file is your secret key. Never share it, never commit it." + +Nora configures branch protection on `main`: +- Pull requests required — no direct pushes +- At least one approval before merge +- Status checks must pass (they'll add these later) + +She sets up team roles: +- Nora: admin (manages settings, merges to main, handles releases) +- Sam: write (creates branches, opens PRs, pushes to feature branches) +- Stakeholders (the CEO, the lead engineer): read-only (view progress, leave comments on PRs) + +Sam opens his first pull request — the zoom-on-selection feature from the previous chapter. Nora reviews it on GitHub, leaves a comment asking for a loading state, Sam adds it, and Nora approves and merges. + +The team has infrastructure. Every change goes through review before reaching `main`. + +--- + +## Chapter 5 — Design & Build Sprint + +Two new people join. **Priya** is a concept designer and illustrator — she'll create SketchSpark's onboarding illustrations, the icon set, and high-fidelity marketing mockups. **Kai** is a frontend engineer who will build the AI generation pipeline, connecting the design work to the model that turns sketches into UI options. + +Four people. Four parallel workstreams: +- **Nora**: UX flows and research updates (text files) +- **Sam**: production UI screens for all core flows (Figma source + PNG exports) +- **Priya**: onboarding illustrations and icon set (large PNGs, SVGs, PSDs) +- **Kai**: AI pipeline configuration (YAML, prompt templates, JSON manifests) + +Each works on a feature branch: + +``` +nora: feature/ux-flows-v2 +sam: feature/production-screens +priya: feature/onboarding-illustrations +kai: feature/ai-pipeline-setup +``` + +Nora acts as integration manager. She reviews each PR before merging to `main`. The workflow: + +1. Designer creates branch, does work, pushes +2. Designer opens PR with description and screenshots +3. Nora reviews — for design work, this means checking screenshots, verifying flows, confirming token consistency +4. If approved, Nora merges to `main` + +Priya's first push takes three minutes. Her onboarding illustrations are 15-30MB each. The team discusses Git LFS but decides to revisit it later — for now, the repo is manageable. + +Sam creates `design-tokens.json` — the bridge between design and engineering. It contains colors, typography scales, spacing values, and border radii. Kai consumes these tokens in the frontend build. This file becomes one of the most frequently committed files in the repo, and the source of the most merge conflicts (everyone touches it). + +Kai sets up the `pipeline/` directory: `model-params.yaml` defines the AI model configuration, `prompts/sketch-to-ui.txt` is the core generation prompt, and `training-data-manifest.json` references the datasets. These are all text files — they diff cleanly, merge predictably, and can be validated with hooks. + +The sprint converges. The sketch-to-options pipeline works end to end for the first time: a user draws something, the model generates 5 UI options, and they appear in Sam's card layout. + +Nora tags the milestone: + +``` +git tag -a v0.5-alpha -m "Alpha: end-to-end sketch-to-options pipeline working" +``` + +She writes the first `CHANGELOG.md` entry and creates a release archive: + +``` +git archive main --prefix='sketchspark-v0.5-alpha/' --format=zip > sketchspark-v0.5-alpha.zip +``` + +The archive goes to the CEO for demo day. The alpha is alive. + +--- + +## Chapter 6 — Public Beta & Community + +The alpha demo goes well. The CEO wants a public beta. The repo goes from private to public on GitHub. + +Going public changes everything. Strangers will see the code, the prompts, the design files. Nora writes `CONTRIBUTING.md` — not for engineers, but for designers: + +- Prompt templates must follow the existing format (system context, then user instruction, then constraints) +- Illustrations must be 2x resolution, brand palette only, PNG export with transparent background +- Icons must sit on a 24x24 grid, 2px stroke, SVG format +- Screen mockups must include both light and dark mode +- All UI contributions must pass WCAG AA contrast requirements + +She expands `README.md` with screenshots of the product, a GIF showing the sketch-to-options flow, a component map, and links to the Figma source files. + +Then Marcus appears. He's a designer in Melbourne — 16 hours ahead of the team. He's been using the beta and thinks the mobile layout generation is weak. He forks the repo, creates `feature/mobile-prompt-template`, and edits `prompts/sketch-to-ui.txt` to add mobile-specific layout constraints. He also adds a new file: `prompts/mobile-layout.txt`. + +He opens a pull request. In the description, he includes before/after screenshots: five generated options from the same sketch, current vs. his improved prompt. The mobile options are noticeably better — less cramped, better touch target sizing. + +Nora reviews the PR the next morning. She's never met Marcus. She leaves feedback: +- The prompt improvement is strong, but the constraint format doesn't match the existing template +- The mobile-layout file needs a header comment explaining when the system uses it vs. the main prompt +- She suggests splitting the touch-target constraint into its own line for readability + +Marcus pushes updates. Nora approves and merges. The whole interaction happens asynchronously over 48 hours, entirely through GitHub comments and annotated screenshots. + +The team sets up GitHub Pages to host product documentation at `sketchspark.github.io` — setup guide, API reference, and contribution guidelines. + +Nora configures the GitHub organization: +- `@core-team`: Nora, Sam, Priya, Kai (write access to all repos) +- `@contributors`: Marcus and other external designers (fork-and-PR workflow) +- `@stakeholders`: CEO, investors (read-only, can comment on PRs) + +The product is no longer just theirs. + +--- + +## Chapter 7 — Production Hardening + +The beta has users. Bugs arrive. Complexity compounds. + +**Sam's stash.** Sam is midway through redesigning the results comparison screen — he's added a new "overlay diff" mode that lets users superimpose two generated options. Half the screens are done, half are placeholders. Then a bug report: the onboarding flow crashes on tablets. The layout breaks at 768px. + +Sam can't commit half-finished work to his branch (the placeholders would confuse reviewers). He stashes: + +``` +git stash push -m "WIP: overlay diff mode for results comparison" +``` + +He switches to `main`, creates `fix/onboarding-tablet-layout`, fixes the responsive breakpoint in the onboarding screens, commits, opens a PR, gets it reviewed, and merges. Then he returns: + +``` +git checkout feature/overlay-diff +git stash pop +``` + +His work-in-progress is exactly where he left it. + +**Priya's blame.** A stakeholder notices that the onboarding illustrations look "off" — the blue tones don't match the brand. Priya uses blame to trace the change: + +``` +git blame illustrations/onboarding/step-2-generate.png +``` + +The file is binary, so blame shows commit metadata but not visual content. She checks the log: + +``` +git log --oneline -- illustrations/onboarding/step-2-generate.png +``` + +Three commits ago, she exported from a file with the wrong color profile. She fixes the source, re-exports, and commits: `Fix color profile on onboarding illustrations (sRGB, not Display P3)`. + +**Nora's interactive staging.** Nora has been updating `product-brief.md` with two unrelated changes: a scope expansion (adding tablet support) and updated user interview findings from round 2. She wants to commit them separately — the scope change needs its own PR and approval, but the research update can merge immediately. + +``` +git add -p product-brief.md +``` + +She stages only the hunks related to interview findings, commits those, then stages and commits the scope expansion separately. Two clean commits instead of one muddled one. + +**Sam's accidental commit to main.** Sam forgets to create a branch. He commits a screen redesign directly to `main`. Branch protection catches it on push — he can't push to `main` without a PR. But the commit exists locally. He fixes it: + +``` +git reset --soft HEAD~1 +git checkout -b feature/screen-redesign +git commit -m "Redesign generation progress screen with loading animation" +``` + +The commit moves to the correct branch. `main` is clean. + +**Priya's messy history.** Priya's icon branch has five commits: + +``` +Add home icon +Fix home icon — wrong stroke width +Update home icon — adjust padding +Add settings icon +Fix settings icon — align to grid +``` + +Before opening her PR, she cleans up with interactive rebase: + +``` +git rebase -i HEAD~5 +``` + +She squashes the home icon commits into one ("Add home navigation icon") and the settings icon commits into one ("Add settings navigation icon"). The PR shows two clean additions instead of five noisy iterations. + +**Kai's submodule.** The AI pipeline has grown complex enough to be its own repository: `sketchspark-ml`. Kai adds it as a submodule of the main product repo: + +``` +git submodule add git@github.com:sketchspark/sketchspark-ml.git pipeline/ +``` + +When the model improves — better option variety, faster generation — Kai updates the submodule pointer in the main repo. The team pulls and gets the latest pipeline version without managing ML code directly. + +--- + +## Chapter 8 — Process & Automation + +The team has grown beyond informal coordination. They need guardrails. + +**Git attributes for binary files.** Nora creates `.gitattributes` to tell Git which files are binary and which can be meaningfully diffed: + +``` +# Binary — don't attempt to diff or merge +*.png binary +*.psd binary +*.fig binary +*.sketch binary + +# Text-based design files — diff normally +*.svg diff +*.md diff +*.json diff +*.yaml diff +*.txt diff + +# Large source files — version but exclude from archives +*.psd export-ignore +*.sketch export-ignore +research/raw-interviews/ export-ignore +``` + +This means `git diff` produces useful output for SVGs, tokens, prompts, and documentation — but doesn't try to diff PNGs or Figma files (which would just show binary garbage). + +**Commit message template.** Nora creates `.gitmessage`: + +``` +[Phase: Component] Short description + +# Phases: Research, Concept, Design, Pipeline, Docs, Fix, Release +# Examples: +# [Design: Results Screen] Add overlay diff comparison mode +# [Research: Persona] Update early-adopter goals after round 2 interviews +# [Pipeline: Prompts] Improve mobile layout generation constraints +# [Fix: Onboarding] Correct tablet breakpoint for step 2 illustration +``` + +She configures it: + +``` +git config commit.template .gitmessage +``` + +Every commit now starts from this template. The `[Phase: Component]` prefix makes `git log --oneline` scannable and `git log --grep="[Design:"` filters to design-only changes. + +**Pre-commit hook.** Nora adds a hook that runs before every commit: + +1. Validates `model-params.yaml` is syntactically correct YAML +2. Checks that prompt templates in `prompts/` don't exceed 4096 tokens (the model's context limit) +3. Warns (but doesn't block) if any PNG file exceeds 5MB + +The hook is a shell script — Nora found a template online and adapted it. She couldn't write it from scratch (she's not a programmer), but she can read it and modify the file size threshold. + +**Commit-msg hook.** A second hook validates that commit messages match the `[Phase: Component]` pattern. If Sam writes "fix stuff", the commit is rejected with a message explaining the expected format. + +**Image metadata diffing.** Nora configures Git to use `exiftool` for PNG diffs. Now `git diff` on an illustration shows metadata changes: dimensions, color profile, export date, DPI. It's not a visual diff, but it catches the color profile mistake that cost Priya time in Chapter 7. + +The team's process is now encoded in the repository itself. New contributors (like Marcus) inherit the rules automatically when they clone. + +--- + +## Chapter 9 — Legacy Migration + +SketchSpark acquires a smaller competitor, **QuickMock**. QuickMock has three years of design assets — mockups, illustrations, user research, and brand materials — stored in a Subversion (SVN) repository on a company server. + +Nora leads the migration. + +**Assessment.** She checks the SVN repo: 2,400 files, 1.2GB total. Most of the size comes from PSD source files (some over 100MB) and high-resolution marketing renders. The text files (research notes, documentation) are small and numerous. + +**Planning.** She decides: +- Import full history for text files (research, documentation, changelogs) — the evolution matters +- Import only the latest version of large binary files (PSDs, high-res PNGs) — old versions of 100MB PSDs aren't useful enough to justify the repo bloat +- Configure Git LFS for files over 10MB going forward +- Map QuickMock's flat folder structure to SketchSpark's organized hierarchy + +**Execution.** She uses `git svn clone` to pull the history: + +``` +git svn clone https://svn.quickmock.internal/trunk quickmock-import --authors-file=authors.txt +``` + +The authors file maps SVN usernames to Git identities so QuickMock's team gets proper attribution. + +Post-import cleanup: +- SVN branch names with `@` suffixes get cleaned up +- Large binaries get migrated to Git LFS: `git lfs migrate import --include="*.psd,*.ai" --above=10mb` +- QuickMock's flat `designs/` folder gets reorganized into SketchSpark's `screens/`, `illustrations/`, and `icons/` structure + +The migration takes a day. The combined repo is 800MB with LFS (down from 1.2GB if everything were inline). Three years of QuickMock's design evolution is now searchable alongside SketchSpark's history. + +Priya notes: "I wish we'd set up LFS from the start. My onboarding illustrations have been bloating the repo since Chapter 5." + +--- + +## Chapter 10 — Scale & Recovery + +It's two days before the v1.0 launch. The team is in final polish mode. Sam is updating screenshots in the documentation. Priya is exporting final marketing assets. Nora is writing release notes. Kai is tuning the model's generation speed. + +Then Sam makes a mistake. + +He means to reset his working directory to discard some local experiments. He types: + +``` +git reset --hard HEAD~3 +``` + +On `main`. He just rewound the main branch by three commits — Nora's release notes, Priya's final marketing illustrations, and Kai's generation speed improvement. All gone from `main`. + +Panic. Then Nora says: "Git doesn't delete anything. It just moves pointers." + +She opens the reflog: + +``` +git reflog +``` + +The reflog shows every position `HEAD` has been in. Three entries up, there's the commit before Sam's reset. She creates a recovery branch: + +``` +git branch recovery a1b2c3d +git checkout recovery +git log --oneline -5 +``` + +All three commits are there. She merges recovery into main: + +``` +git merge recovery +``` + +Everything is restored. The launch stays on schedule. + +This moment — the near-disaster and the recovery — becomes the frame for understanding Git internals: + +**Objects.** Every file version, every directory snapshot, every commit is stored as an object with a unique hash. Nora explains: "When you committed those release notes, Git created an object. When Sam reset `main`, Git didn't delete the object — it just moved the `main` label to point at an older one. The release notes object was still there, just unreachable through normal commands." + +**References.** Branches are labels. Tags are labels. HEAD is a label. Moving them — even destructively — doesn't destroy the underlying objects. Sam's `reset --hard` moved the `main` label backward. Nora's `branch recovery` created a new label pointing at the still-existing commit. + +**Reflog.** Git keeps a log of every label movement for at least 30 days. Even if Sam had deleted the branch, the reflog would still know where it pointed. The reflog is the safety net that makes Git's model robust against human error. + +**Packfiles.** Priya asks why `git clone` takes 45 seconds for a repo with thousands of files. Nora explains: Git packs similar objects together using delta compression. When Priya commits a slightly modified illustration, Git doesn't store a second full copy — it stores the difference. But very large binary files (her PSDs) resist delta compression, which is why LFS exists. + +The internals chapter isn't about cryptographic hash functions or the Git object database's implementation. It's about understanding *why your work is never truly lost* — and why that matters when months of research, design, and AI configuration are at stake. + +--- + +## Appendix A — Tooling Choices + +The team never agreed on one tool. That turned out fine. + +**Nora** uses the command line. Her work is text-heavy — product briefs, research notes, user flows. She types `git status`, `git diff`, `git log --oneline --graph` dozens of times a day. The CLI is fastest for her. + +**Sam** uses VS Code. He edits `design-tokens.json` and `user-flows.md` with Git's inline gutter indicators showing what changed since the last commit. The built-in source control panel lets him stage individual hunks without learning `git add -p` syntax. He reviews PRs with the GitHub Pull Requests extension. + +**Priya** uses GitHub Desktop. She stages files by checking boxes. She sees a visual list of changed files — critical when her commits include a dozen illustration exports. Drag-and-drop staging and clear binary file indicators ("This file has changed but can't be displayed") match how she thinks about her work. + +**Kai** uses JetBrains (WebStorm). The integrated terminal, diff viewer, and Git log sit alongside his Python and JavaScript code. He resolves merge conflicts in the three-pane merge tool without leaving his IDE. + +The appendix presents a decision tree: +- "I mainly write text and research documents" → CLI or VS Code +- "I work with lots of image files" → GitHub Desktop +- "I write code alongside design work" → VS Code or JetBrains +- "I want the simplest possible interface" → GitHub Desktop +- "I want maximum control" → CLI + +No choice is wrong. The best Git tool is the one you'll actually use. + +--- + +## Appendix B — Tool Integration + +Kai gives the team a look behind the curtain. + +SketchSpark's own architecture uses Git internally. When a user uploads a sketch and the system generates 5 UI options, each option is created as a lightweight branch in a temporary repository using **libgit2** (C library, called from the Python backend). The user's "compare options" screen is reading from Git branches. The "pick this one" button is a merge. The product's UX is a Git workflow — the user just never sees `git` commands. + +This reframing — "you've been using Git concepts all along without knowing it" — lands differently now that readers understand branches and merges from their own experience. + +Priya is intrigued by a different angle. She wants to automate her export workflow: every time she exports illustrations from her design tool, a script should auto-commit them to Git. She finds **Dulwich**, a Python Git library, and writes a script: + +```python +# Simplified — watches export folder and auto-commits new PNGs +from dulwich.repo import Repo +repo = Repo(".") +repo.stage(["illustrations/onboarding/step-1-upload.png"]) +repo.do_commit(b"Auto-export: updated onboarding illustration step 1") +``` + +It's ten lines of code (Kai helps with the details). Now her Git workflow is: export from design tool → script commits automatically → she opens a PR when the batch is ready. The manual `git add` / `git commit` cycle disappears for her binary file workflow. + +The appendix isn't about learning to write Git libraries. It's about understanding that the tools designers already use — GitHub Desktop, Figma plugins, CI/CD pipelines — are built on these libraries. Knowing they exist demystifies "how does GitHub Desktop work?" and opens the door to simple automation. + +--- + +## Appendix C — Reference + +The command reference is organized by SketchSpark workflow, not alphabetical command taxonomy. + +**Starting a Project** +- `git init` — Create a new repository (Nora in Chapter 2) +- `git clone` — Copy an existing repository (Sam joining in Chapter 3) +- `git config` — Set your name, email, editor, commit template (Chapter 1, Chapter 8) + +**Daily Design Work** +- `git status` — What's changed since my last commit? +- `git add` — Select files to include in the next commit +- `git add -p` — Select specific changes within a file (Nora in Chapter 7) +- `git commit` — Save a checkpoint with a message +- `git diff` — What exactly changed? (works for text files; limited for binary) +- `git stash` — Set aside work-in-progress temporarily (Sam in Chapter 7) + +**Exploring & Branching** +- `git branch` — List, create, or delete branches +- `git checkout` / `git switch` — Move to a different branch +- `git merge` — Combine one branch into another +- `git rebase` — Replay commits onto a different base (Sam in Chapter 3) + +**Collaborating** +- `git remote` — Manage connections to shared repositories +- `git push` — Send your commits to the shared repository +- `git pull` — Download and merge teammates' changes +- `git fetch` — Download without merging (check first, merge later) + +**Reviewing History** +- `git log` — See commit history (with `--oneline --graph` for visual overview) +- `git log -S "keyword"` — Find when a specific term was added or removed +- `git blame` — Find who last changed each line of a file (Priya in Chapter 7) +- `git show` — Display a specific commit's contents + +**Shipping a Release** +- `git tag` — Mark a commit as a release (v0.1-concept, v0.5-alpha, v1.0) +- `git archive` — Create a distributable zip/tar without Git history + +**Fixing Mistakes** +- `git restore` — Discard uncommitted changes to a file +- `git restore --staged` — Unstage a file without losing changes +- `git reset --soft HEAD~1` — Undo the last commit, keep changes staged (Sam in Chapter 7) +- `git revert` — Create a new commit that undoes a previous commit (safe for shared branches) +- `git reflog` — Find lost commits after a destructive operation (Nora in Chapter 10) + +**Maintaining Quality** +- `git clean` — Remove untracked files (caution: irreversible for design exports) +- `git lfs` — Manage large binary files (illustrations, PSDs) without bloating the repo + +Each command links back to the chapter where it appears in the storyline, so readers can revisit the full context. + +--- + +## Recurring Threads + +These themes weave through every chapter, creating continuity beyond the plot: + +**Binary vs. Text.** Introduced in Chapter 1 (Nora's question about Sketch files), demonstrated in Chapter 2 (wireframe PNGs vs. markdown briefs), painful in Chapter 5 (Priya's large illustrations), configured in Chapter 8 (`.gitattributes`), resolved in Chapter 9 (Git LFS). Every chapter reinforces: text files are Git's strength; binary files require extra care. + +**The Five Options.** The product generates 5 options from 1 sketch. Git creates parallel branches from 1 commit. This parallel is explicit in Chapter 3 (Sam's three `option/` branches), implicit in Chapter 5 (four parallel feature branches), and architectural in Appendix B (the product uses Git branches internally). The metaphor deepens as the reader's Git knowledge grows. + +**Design Decisions as Commits.** Every commit in the storyline represents a design decision — not a code change. "Update primary color for accessibility," "Add tablet breakpoint to onboarding," "Improve mobile generation prompt." This reframes Git from a developer tool to a design decision ledger. + +**Progressive Team Growth.** Chapter 1: solo. Chapter 2: solo with structure. Chapter 3: pair. Chapter 5: team of four. Chapter 6: open community. Each growth stage introduces the Git workflow that stage demands — tags when you're solo, branches when you're two, integration manager when you're four, fork-and-PR when you're open source. + +**The Safety Net.** Git's ability to recover from mistakes is introduced gently (undo in Chapter 2), tested (reset in Chapter 7), and fully proven (reflog recovery in Chapter 10). By the final chapter, the reader trusts that Git protects their work — the same trust that motivated Nora to adopt it after her file loss in Chapter 1. The story ends where it began: your work is never truly lost. From 0c21fb605592487cb0e293bd1dc7e4f4fa87fc45 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 4 Apr 2026 22:55:55 +0000 Subject: [PATCH 13/18] Add section-by-section outlines for all 13 chapters and appendices Each outline maps the original Pro Git sections to the SketchSpark storyline, specifying what stays, what gets rewritten, what's new, and what gets cut. Includes target line counts and specific example replacements for every section. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/01-introduction/outline.md | 140 ++++++++++++ 00-notes/02-git-basics/outline.md | 199 ++++++++++++++++++ 00-notes/03-git-branching/outline.md | 158 ++++++++++++++ 00-notes/04-git-server/outline.md | 142 +++++++++++++ 00-notes/05-distributed-git/outline.md | 143 +++++++++++++ 00-notes/06-github/outline.md | 134 ++++++++++++ 00-notes/07-git-tools/outline.md | 157 ++++++++++++++ 00-notes/08-customizing-git/outline.md | 136 ++++++++++++ 00-notes/09-git-and-other-scms/outline.md | 90 ++++++++ 00-notes/10-git-internals/outline.md | 153 ++++++++++++++ .../A-git-in-other-environments/outline.md | 92 ++++++++ 00-notes/B-embedding-git/outline.md | 106 ++++++++++ 00-notes/C-git-commands/outline.md | 96 +++++++++ 13 files changed, 1746 insertions(+) create mode 100644 00-notes/01-introduction/outline.md create mode 100644 00-notes/02-git-basics/outline.md create mode 100644 00-notes/03-git-branching/outline.md create mode 100644 00-notes/04-git-server/outline.md create mode 100644 00-notes/05-distributed-git/outline.md create mode 100644 00-notes/06-github/outline.md create mode 100644 00-notes/07-git-tools/outline.md create mode 100644 00-notes/08-customizing-git/outline.md create mode 100644 00-notes/09-git-and-other-scms/outline.md create mode 100644 00-notes/10-git-internals/outline.md create mode 100644 00-notes/A-git-in-other-environments/outline.md create mode 100644 00-notes/B-embedding-git/outline.md create mode 100644 00-notes/C-git-commands/outline.md diff --git a/00-notes/01-introduction/outline.md b/00-notes/01-introduction/outline.md new file mode 100644 index 000000000..877c27ef5 --- /dev/null +++ b/00-notes/01-introduction/outline.md @@ -0,0 +1,140 @@ +# Chapter 1: Getting Started — Section Outline + +> **Storyline phase**: Research & Discovery +> **Characters**: Nora (solo) +> **Key event**: Nora loses research files to a sync conflict, discovers Git + +--- + +## Section: About Version Control (`about-version-control.asc`) +**Original**: 61 lines | **Action**: REWRITE + +### Keep +- Core structure: local → centralized → distributed progression +- Diagrams (local VCS, CVCS, DVCS) — update captions only + +### Rewrite +- **Opening hook**: Replace generic "graphic designers or web designers" mention (line 8) with Nora's story — she's running user research for SketchSpark and loses a week of interview notes when her cloud sync overwrites the folder with a stale version +- **Local VCS**: Replace RCS reference with "saving copies in dated folders" — `interview-notes-v1/`, `interview-notes-FINAL/`, `interview-notes-FINAL-v3-REAL/`. Nora's actual workflow before Git. +- **Centralized VCS**: Replace CVS/Subversion/Perforce with shared Google Drive analogy. "Everyone connects to one place. If it's down or conflicts, work is lost." Reference Figma's shared file model as another example designers know. +- **Distributed VCS**: Replace Mercurial/Darcs with practical framing. "Every team member has the full history locally. If the cloud disappears, your laptop still has everything." + +### New +- After DVCS section, add 2-line SketchSpark context: "In this book, we'll follow a product called SketchSpark — an AI-powered prototyping tool — from research through launch. Git protects every artifact the team creates along the way." + +--- + +## Section: A Short History of Git (`history.asc`) +**Original**: 20 lines | **Action**: TRIM + REFRAME + +### Keep +- Design goals list (speed, simple design, non-linear development, fully distributed, large projects) + +### Rewrite +- Replace Linux kernel / BitKeeper backstory (irrelevant to designers) with 2-line summary: "Git was created in 2005 for the Linux kernel project. Its design goals — speed, branching, and full local history — make it equally suited to managing design projects." +- Add after goals list: "For a design team, these goals mean: Git handles hundreds of files, supports exploring multiple directions simultaneously, and works fully offline." + +### Target +- ~12 lines (down from 20) + +--- + +## Section: What is Git? (`what-is-git.asc`) +**Original**: 109 lines | **Action**: REWRITE + +### Keep +- Section structure (Snapshots, Local Operations, Integrity, Only Adds Data, Three States) +- Diagrams (snapshots vs. deltas, three states) +- Three-step workflow summary + +### Rewrite +- **Snapshots**: Replace "stream of snapshots" language with "Git takes a picture of your entire project every time you commit — like a save point you can always return to." Connect to Nora: "Each commit captures every research document, wireframe, and design file exactly as they are at that moment." +- **Local Operations**: Add: "You can review your project history, compare versions, and commit new work without internet. Critical when working on planes, in cafes, or when the office Wi-Fi goes down." +- **Integrity**: Simplify SHA-1 to: "Every commit is identified uniquely and permanently. You don't need to understand the math — just know that Git can always detect if something has been corrupted or changed." +- **Only Adds Data**: Add Nora's reassurance: "After losing those interview notes, this is what sold me on Git. Once you commit, that snapshot is safe. You'd have to go out of your way to destroy it." +- **Three States**: Map to Nora's workflow: + - Modified = "You've updated the competitive analysis but haven't marked it as ready" + - Staged = "You've selected which updates to bundle into this checkpoint" + - Committed = "The checkpoint is permanent — you can always come back to it" + +### New +- Add sidebar: "Git and Design Files — What to Know Early" + - Text files (`.md`, `.json`, `.yaml`, `.txt`, `.svg`) → Git tracks every change, shows diffs, merges cleanly + - Binary files (`.png`, `.psd`, `.sketch`, `.fig`) → Git stores them but can't show what changed visually, can't merge + - "This distinction — text vs. binary — comes up in every chapter. Keep it in mind." + +--- + +## Section: The Command Line (`command-line.asc`) +**Original**: 11 lines | **Action**: REWRITE + +### Rewrite +- Soften CLI-only stance. Replace "only place you can run all Git commands" with balanced framing: + - "This book teaches Git through the command line because every Git concept maps directly to a command. Once you understand the commands, any GUI tool (GitHub Desktop, VS Code, GitKraken) will make sense." + - "If you prefer a visual interface, that's fine. Appendix A covers GUI options. But learning the commands first gives you the vocabulary to understand what the GUI is doing." +- Add: "Nora started with the command line. Sam (who joins in Chapter 3) prefers VS Code. Priya (Chapter 5) uses GitHub Desktop. All three are valid." + +--- + +## Section: Installing Git (`installing.asc`) +**Original**: 137 lines | **Action**: TRIM + +### Keep +- Linux (dnf/apt), macOS (Xcode CLT), Windows (git-scm.com) instructions +- Basic structure + +### Cut +- "Installing from Source" section (lines 64-137, 73 lines) — move to appendix or link. No designer will compile Git from source. + +### New +- Add after installation: verification step — `git --version` to confirm it worked +- Add note: "If you prefer a GUI, install GitHub Desktop (desktop.github.com) alongside Git. It includes Git and provides a visual interface." + +### Target +- ~70 lines (down from 137) + +--- + +## Section: First-Time Git Setup (`first-time-setup.asc`) +**Original**: 136 lines | **Action**: REWRITE + +### Keep +- Identity setup commands (`git config --global user.name`, `user.email`) +- Default branch name (`init.defaultBranch main`) +- Checking settings (`git config --list`) + +### Rewrite +- Simplify three-level config hierarchy to: "Git has settings at three levels: system-wide, your user account, and per-project. The user-level (`--global`) is all you need right now." +- Replace editor setup (Vim/Emacs/Notepad++) with: "If you use VS Code: `git config --global core.editor 'code --wait'`". Add one-liner for other common editors as a table. +- Add Nora connection: "Just like Figma records who made each change, Git attributes every commit to you using this name and email." + +### Cut +- Detailed editor configuration table (lines 50-84) — replace with 3-line quick reference +- Windows-specific registry detail + +### Target +- ~80 lines (down from 136) + +--- + +## Section: Getting Help (`help.asc`) +**Original**: 50 lines | **Action**: TRIM + UPDATE + +### Keep +- Three help syntax variants +- `git add -h` quick help example + +### Rewrite +- Replace IRC/Libera Chat references with modern resources: Stack Overflow, GitHub Community, Discord servers +- Reorder: put `-h` flag first (quick, easy), then `git help <verb>` for full docs + +### Target +- ~35 lines (down from 50) + +--- + +## Chapter Summary Section +**Action**: REWRITE + +### New +- Connect to storyline: "Nora has Git installed, configured, and understands the core concepts — snapshots, the three states, and the text-vs-binary distinction. In the next chapter, she creates the SketchSpark repository and starts tracking the product's concept design artifacts." diff --git a/00-notes/02-git-basics/outline.md b/00-notes/02-git-basics/outline.md new file mode 100644 index 000000000..bcb4c954c --- /dev/null +++ b/00-notes/02-git-basics/outline.md @@ -0,0 +1,199 @@ +# Chapter 2: Git Basics — Section Outline + +> **Storyline phase**: Concept Design +> **Characters**: Nora (solo) +> **Key event**: Nora creates the SketchSpark repo, learns the daily Git workflow + +--- + +## Section: Getting a Repository (`getting-a-repository.asc`) +**Original**: 88 lines | **Action**: REWRITE EXAMPLES + +### Keep +- Two-path structure: init vs. clone +- Command syntax and explanations +- Protocol mention for clone + +### Rewrite +- **Init example**: Replace generic `my_project` with Nora initializing the SketchSpark directory: + ``` + cd sketchspark + git init + git add product-brief.md research/personas/ concept/user-flows.md + git commit -m "Add product brief, personas, and initial user flows" + ``` +- **Clone example**: Replace `libgit2` with: `git clone https://github.com/sketchspark/sketchspark.git` — framed as "this is how Sam will join the project in the next chapter" +- Add `.gitignore` mention here (currently absent): "Before your first commit, create a `.gitignore` file to exclude temp files your design tools generate." + +### New +- Add sidebar: "What Belongs in a Design Project Repo?" — text files (briefs, research, tokens, docs), exported assets (PNGs, SVGs), source files (discussion of tradeoffs with large binaries) + +--- + +## Section: Recording Changes (`recording-changes.asc`) +**Original**: 630 lines | **Action**: REWRITE EXAMPLES, TRIM + +### Keep +- File lifecycle diagram +- Status → stage → commit workflow structure +- `.gitignore` pattern syntax +- `git diff` explanation +- Commit message guidance +- File removal and moving + +### Rewrite +- **All file references**: Replace `benchmarks.rb`, `CONTRIBUTING.md`, `Rakefile`, `lib/simplegit.rb` with: + - `product-brief.md` (text, mergeable) + - `research/competitive-analysis.md` (text) + - `concept/wireframes/sketch-input.png` (binary) + - `design-tokens.json` (structured text, later chapters) +- **Status example**: Nora checks status after adding wireframe exports — show both tracked text files and new binary files +- **Staging explanation**: "Staging is selecting which changes to bundle into this commit. Nora updated both the product brief and the wireframes, but she commits them separately — text and binary changes serve different review purposes." +- **`.gitignore`**: Replace default patterns with design-specific template: + ``` + .DS_Store + __MACOSX/ + Thumbs.db + *.sketch~ + *.figma_cache + node_modules/ + ``` +- **Diff**: Show `git diff` on `product-brief.md` (useful, shows word changes) and note: "Running `git diff` on `sketch-input.png` shows nothing useful — Git knows the file changed but can't display visual differences for binary files." +- **Commit messages**: Replace generic messages with SketchSpark examples: + - `Add product brief and initial user flows` + - `Add wireframes for sketch input and results comparison screens` + - `Update competitive analysis with two additional tools` + +### Cut +- Reduce `git diff --staged` vs `git diff` explanation (keep one clear example, cut repetition) +- Trim "Skipping the Staging Area" — keep as a note, not a full subsection + +### New +- Add "Commit Messages for Design Work" sidebar: + - Good: `Add competitive analysis with 6 prototyping tools reviewed` + - Good: `Update product brief — change from 3 to 5 parallel options` + - Bad: `Updated stuff` / `WIP` / `changes` + - Tip: "Write messages that help your future self (or teammate) understand *why*, not just *what*." + +--- + +## Section: Viewing the Commit History (`viewing-history.asc`) +**Original**: 307 lines | **Action**: REWRITE EXAMPLES, TRIM + +### Keep +- `git log` with common flags (`--oneline`, `--graph`, `--stat`) +- Limiting output (`--since`, `--author`, `-S`) +- Format table (useful reference) + +### Rewrite +- All example output uses SketchSpark commits: + ``` + a1b2c3d Add wireframes for sketch input and results comparison screens + d4e5f6g Update competitive analysis with two additional tools + h7i8j9k Add product brief, personas, and initial user flows + ``` +- **`-S` search**: `git log -S "5 options" -- product-brief.md` — Nora traces when the product concept changed from 3 options to 5 +- **`--author`**: Preview for later chapters: "When Sam joins, `git log --author='Sam'` shows only his commits." +- **`--stat`**: Show file-level summary including a binary file (PNG) to demonstrate that stats work for binary too (shows bytes changed) + +### Trim +- Reduce format specifier table to the 5 most useful entries +- Cut `--pretty=format:` deep dive — keep one example, link to docs for full reference + +--- + +## Section: Undoing Things (`undoing.asc`) +**Original**: 236 lines | **Action**: REWRITE EXAMPLES + +### Keep +- Amend workflow +- Both old (`git reset`, `git checkout`) and new (`git restore`) unstaging/unmodifying +- Warnings about dangerous operations + +### Rewrite +- **Amend scenario**: Nora commits the product brief but forgets to include the updated persona document: + ``` + git commit -m "Add product brief and personas" + # Oops — forgot early-adopter.md + git add research/personas/early-adopter.md + git commit --amend + ``` +- **Unstage scenario**: Nora accidentally stages a large wireframe PNG she's not ready to commit: + ``` + git restore --staged concept/wireframes/results-comparison.png + ``` +- **Discard changes**: Nora decides her edits to `user-flows.md` went in the wrong direction: + ``` + git restore concept/user-flows.md + ``` + Warning: "This throws away uncommitted changes permanently. Unlike committed work, uncommitted changes can't be recovered." + +### New +- Add Nora's reflection: "This is why I commit frequently — committed work is safe. Uncommitted work is not." + +--- + +## Section: Working with Remotes (`remotes.asc`) +**Original**: 241 lines | **Action**: REWRITE EXAMPLES, TRIM + +### Keep +- Core concepts: origin, fetch, pull, push +- Adding/removing remotes +- Inspecting remotes + +### Rewrite +- Replace `pb` (Paul's branch) / `teamone` / `bakkdoor` with design-relevant remotes: + - `origin` = SketchSpark's main repo on GitHub (set up in Chapter 4) + - Preview: "In Chapter 5, when Kai joins with the AI pipeline, his repository may become a second remote." +- All URL examples use `github.com/sketchspark/sketchspark.git` +- Simplify `git remote show origin` output to show only the branches relevant to the storyline + +### Trim +- Reduce multiple-remote complexity — one remote (`origin`) is enough for this chapter. Multiple remotes return in Chapter 5. + +--- + +## Section: Tagging (`tagging.asc`) +**Original**: 300 lines | **Action**: REWRITE EXAMPLES, TRIM + +### Keep +- Annotated vs. lightweight distinction +- Creating, listing, sharing, deleting tags +- Tagging past commits + +### Rewrite +- Replace generic `v1.4` / `v1.5` with SketchSpark milestones: + ``` + git tag -a v0.1-concept -m "Research complete, concept approved, entering UI exploration" + ``` +- Frame tags as product milestones: "Tags mark moments you'll want to return to — concept approval, alpha release, public beta. They're permanent bookmarks in your project history." + +### Trim +- Reduce "Checking out Tags" to a note about detached HEAD — designers won't use this often +- Cut lightweight tag detail to 2 lines — annotated tags are the recommendation + +--- + +## Section: Git Aliases (`aliases.asc`) +**Original**: 71 lines | **Action**: REWRITE EXAMPLES + +### Keep +- Concept and syntax +- External command aliases (`!`) + +### Rewrite +- Replace generic aliases with SketchSpark-relevant ones: + ``` + git config --global alias.last 'log -1 HEAD' + git config --global alias.visual 'log --oneline --graph --all' + git config --global alias.recent 'log --oneline -10' + ``` +- Add: "Nora creates an alias to check what changed in research files: `git config --global alias.research-log 'log --oneline -- research/'`" + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "Nora's SketchSpark repo has a product brief, personas, a competitive analysis, user flows, and wireframes — all versioned, all recoverable. She's tagged the concept milestone (`v0.1-concept`) and established a commit rhythm. In the next chapter, Sam joins the project and they discover branches — the feature that makes Git indispensable for parallel design exploration." diff --git a/00-notes/03-git-branching/outline.md b/00-notes/03-git-branching/outline.md new file mode 100644 index 000000000..c25b68ae8 --- /dev/null +++ b/00-notes/03-git-branching/outline.md @@ -0,0 +1,158 @@ +# Chapter 3: Git Branching — Section Outline + +> **Storyline phase**: Parallel Exploration +> **Characters**: Nora, Sam (joins this chapter) +> **Key event**: Sam explores 3 UI directions as branches; first merge conflict on `user-flows.md` + +--- + +## Section: Branches in a Nutshell (`nutshell.asc`) +**Original**: 211 lines | **Action**: REWRITE + +### Keep +- Core explanation of how branches work (pointer to a commit) +- HEAD as "where you are now" +- Diagrams showing branch pointer movement +- `git branch`, `git checkout`, `git switch` commands + +### Rewrite +- **Opening**: Replace abstract pointer explanation with: "A branch is a parallel workspace. You can explore an idea without affecting anyone else's work — and switch back to the stable version instantly." +- **Creating a branch**: Replace `testing` with `option/card-layout` — Sam's first UI direction for the results screen +- **HEAD analogy**: "HEAD is which workspace you're currently in. When you switch branches, HEAD moves, and your files update to match." +- **All file references**: Replace generic files with SketchSpark artifacts +- Remove "41 bytes" lightweight emphasis — provides no actionable value for designers + +### New +- Add after branch creation: "Sam will create three branches to explore three different layouts for the results screen — the screen where users see 5 generated UI options. This mirrors the product's own concept: multiple options from a single starting point." + +--- + +## Section: Basic Branching and Merging (`basic-branching-and-merging.asc`) +**Original**: 319 lines | **Action**: REWRITE + +### Keep +- Three-part structure: branching → merging → conflict resolution +- Fast-forward merge concept +- Three-way merge concept +- Conflict markers explanation +- Diagrams + +### Rewrite +- **Branching scenario**: Replace issue #53 / hotfix with SketchSpark story: + - Sam is working on `option/card-layout` (results screen as a card grid) + - Nora discovers a missing upload error state on `main` + - Sam creates `fix/sketch-input-upload-error`, fixes the error state, merges to `main` + - Sam returns to `option/card-layout` +- **Merge scenario**: Sam finishes the card layout and merges to `main` +- **Conflict scenario**: Both Nora and Sam edited `concept/user-flows.md` — Nora refined the upload step, Sam added a "compare options" step. Show the conflict markers with design-relevant content: + ``` + <<<<<<< HEAD + 3. User uploads sketch via drag-and-drop or file picker + ======= + 3. User uploads sketch via drag-and-drop + 4. System generates 5 options and displays comparison view + >>>>>>> option/card-layout + ``` + Resolution: keep both — Nora's refined upload step AND Sam's comparison step. +- Add after conflict resolution: "This was a text file, so Git showed exactly where the conflict was. If this had been a PNG or Figma file, Git couldn't show the conflict — you'd need to open both versions and manually compare." + +--- + +## Section: Branch Management (`branch-management.asc`) +**Original**: 184 lines | **Action**: REWRITE EXAMPLES, TRIM + +### Keep +- `git branch -v`, `--merged`, `--no-merged` +- Branch deletion + +### Rewrite +- Replace generic branch names with SketchSpark names: + - `option/card-layout` (merged) + - `option/list-layout` (not merged — still exploring) + - `option/canvas-freeform` (not merged) + - `fix/sketch-input-upload-error` (merged) +- Show `git branch --merged` to identify which exploration branches have been integrated + +### Trim +- Cut "Changing the master branch name" subsection (lines 80-184) — useful but not storyline-relevant. Keep as a note linking to the full guide. + +### New +- Add "Branch Naming for Design Projects" sidebar: + - `option/` — design explorations (may be discarded) + - `feature/` — approved work heading to production + - `fix/` — corrections to existing work + - `research/` — investigation branches (new interviews, usability tests) + +--- + +## Section: Branching Workflows (`workflows.asc`) +**Original**: 64 lines | **Action**: REWRITE + +### Keep +- Long-running branches concept +- Topic branches concept +- Diagrams + +### Rewrite +- **Long-running branches**: Map stability levels to SketchSpark: + - `main` = approved, stable work (could ship at any time) + - `develop` = reviewed work queued for next milestone (used in later chapters) + - `option/*` and `feature/*` = work-in-progress +- **Topic branches**: Frame as "each design exploration gets its own branch." Sam's three `option/` branches are the example. +- Replace "pu" (proposed updates) with design-relevant naming +- Add: "The team reviews all three options. They choose the card layout. The other two branches are archived — the work isn't lost, just not merged." + +--- + +## Section: Remote Branches (`remote-branches.asc`) +**Original**: 237 lines | **Action**: REWRITE EXAMPLES, TRIM + +### Keep +- Remote-tracking branches concept (`origin/main`) +- Pushing and tracking +- `git branch -vv` for tracking status +- Pulling = fetch + merge + +### Rewrite +- Replace `serverfix` with SketchSpark branches: `feature/zoom-on-selection` +- Replace multi-server example (too complex for this stage) with single-remote workflow +- Add: "When Sam pushes `option/card-layout` to GitHub, it becomes `origin/option/card-layout`. Nora can fetch it, review it locally, and merge it through a pull request." + +### Trim +- Reduce multi-remote complexity — save for Chapter 5 +- Cut detailed refspec discussion — save for Chapter 10 + +--- + +## Section: Rebasing (`rebasing.asc`) +**Original**: 241 lines | **Action**: REWRITE, SIMPLIFY + +### Keep +- Basic rebase concept and workflow +- Rebase vs. merge comparison +- "Do not rebase commits that exist outside your repository" warning +- Diagrams + +### Rewrite +- **Basic rebase**: Sam rebases `option/list-layout` onto `main` (which now includes the merged card layout) to see if any ideas from the list layout are worth carrying forward on the updated codebase. +- **Analogy**: "Rebasing replays your changes on top of someone else's latest work — like re-sketching your concept using the team's updated component library as the foundation." +- **Perils**: "If Sam rebases a branch he's already pushed and shared with Nora, it rewrites history she's already seen. Don't rebase shared branches." + +### Trim +- Cut `--onto` advanced rebase (move to Chapter 7) +- Simplify "Rebase When You Rebase" recovery section — mention it exists, link to Chapter 7 for details +- Cut patch-id explanation to 1 line + +### New +- Add decision guide: "Should I rebase or merge?" + - "Working alone on a local branch? Rebase to keep history clean." + - "Branch is shared with teammates? Merge to preserve everyone's work." + - "Not sure? Merge. It's always safe." + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "Sam explored three directions for the results screen. The team chose one, archived two, and cherry-picked an interaction from a third. They resolved their first merge conflict — in a text file, where Git could help. They know it won't be as easy with binary files. In the next chapter, the project outgrows Nora's laptop and moves to GitHub." diff --git a/00-notes/04-git-server/outline.md b/00-notes/04-git-server/outline.md new file mode 100644 index 000000000..f953e91da --- /dev/null +++ b/00-notes/04-git-server/outline.md @@ -0,0 +1,142 @@ +# Chapter 4: Git on the Server — Section Outline + +> **Storyline phase**: Team Infrastructure +> **Characters**: Nora, Sam +> **Key event**: SketchSpark moves to GitHub; branch protection and roles established + +--- + +## Structural Change: Reorder Sections + +The original chapter buries hosted options at the end. Designers almost always use hosted platforms. Reorder: + +1. Third Party Hosted Options (moved from position 9 to position 1) +2. The Protocols (trimmed) +3. SSH Key Generation (simplified) +4. GitLab (kept, reframed) +5. Getting Git on a Server (moved to "Advanced" section) +6. Setting Up the Server (moved to "Advanced") +7. Git Daemon (moved to "Advanced") +8. Smart HTTP (moved to "Advanced") +9. GitWeb (moved to "Advanced") + +--- + +## Section: Third Party Hosted Options (`hosted.asc`) — MOVED TO LEAD +**Original**: 11 lines | **Action**: EXPAND + +### Keep +- Concept of hosted options + +### Rewrite +- Expand from 11 lines to ~60 lines +- Add comparison table: GitHub vs. GitLab vs. Bitbucket (features relevant to design teams: PR reviews, branch protection, project boards, Pages for docs, free tier) +- Add Nora's decision: "The SketchSpark team picks GitHub — they already have accounts, the PR review workflow is visual, and GitHub Pages will host their product documentation later." + +### New +- "Quick Start: GitHub for Your Design Project" walkthrough: + 1. Create organization → create repository → push existing local repo + 2. Invite Sam as collaborator + 3. Enable branch protection on `main` (require PR, require 1 approval) + 4. Set up team roles (admin, write, read-only) +- This replaces the need for most of the server setup sections + +--- + +## Section: The Protocols (`protocols.asc`) +**Original**: 212 lines | **Action**: TRIM HEAVILY + +### Keep +- HTTPS and SSH protocol descriptions (the only two designers use) +- Brief pros/cons of each + +### Rewrite +- Frame as "Two ways to connect to GitHub": HTTPS (simpler, uses password/token) and SSH (more secure, uses key pair) +- Replace security language with designer framing: "HTTPS asks for your password each time (or a saved token). SSH uses a key file on your computer — set it up once and forget it." + +### Cut +- Local Protocol (lines 6-64) — move to advanced/appendix +- Dumb HTTP (irrelevant) +- Git Protocol (lines 180-211) — irrelevant for design teams + +### Target +- ~60 lines (down from 212) + +--- + +## Section: Generating Your SSH Public Key (`generating-ssh-key.asc`) +**Original**: 58 lines | **Action**: SIMPLIFY + +### Keep +- Key generation command (`ssh-keygen`) +- Checking for existing keys +- Displaying public key + +### Rewrite +- Sam's first SSH key: "Sam has never used SSH. Nora walks him through it." +- Simplify passphrase guidance: "Choose a passphrase you'll remember. It protects your key if your laptop is lost or stolen." +- Add: "The `.pub` file is safe to share — give it to GitHub. The other file is your secret key. Never share it, never commit it to a repository." + +### Cut +- `ssh-agent` discussion — too advanced for this stage +- Detailed key inspection + +### Target +- ~35 lines (down from 58) + +--- + +## Section: GitLab (`gitlab.asc`) +**Original**: 131 lines | **Action**: REFRAME + +### Keep +- Basic structure (installation, administration, usage, collaboration) +- Merge request workflow + +### Rewrite +- Reframe administration terms for design teams: + - Users → "Team Members" + - Groups → "Design Teams" + - Projects → "Repositories" +- Add design governance context: branch protection rules, merge request assignment, labels (`new-component`, `bug-fix`, `breaking-change`) +- Note: "If your organization uses GitLab instead of GitHub, the core concepts are identical — repositories, branches, merge requests (GitLab's term for pull requests), and code review." + +### Trim +- Cut installation details to: "GitLab can be self-hosted or used at gitlab.com. Ask your IT team for the URL." + +--- + +## Sections Moved to "Advanced: Self-Hosting" Block + +The following sections are wrapped in a single prefaced block: + +> "The sections below cover self-hosted Git servers. Most design teams use GitHub or GitLab and can skip this entirely. Read on only if your organization requires on-premises hosting." + +### Getting Git on a Server (`git-on-a-server.asc`) +**Original**: 102 lines | **Action**: KEEP, ADD NOTE +- Add intro note directing designers to the hosted section +- Replace `my_project` with `sketchspark.git` +- Keep bare repository explanation: "A bare repository is like a server copy — not edited directly, only used as a central reference point." + +### Setting Up the Server (`setting-up-server.asc`) +**Original**: 150 lines | **Action**: KEEP AS-IS +- Mark clearly as "for system administrators" + +### Git Daemon (`git-daemon.asc`) +**Original**: 67 lines | **Action**: KEEP AS-IS, ADD NOTE +- Add: "Rarely used by design teams. Skip unless your sysadmin specifically requires it." + +### Smart HTTP (`smart-http.asc`) +**Original**: 73 lines | **Action**: KEEP AS-IS, ADD NOTE + +### GitWeb (`gitweb.asc`) +**Original**: 71 lines | **Action**: KEEP AS-IS, ADD NOTE +- Add: "If you're using GitHub or GitLab, they provide much better interfaces. This section is for self-hosted setups only." + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "SketchSpark lives on GitHub. The team has branch protection, roles, and a pull request workflow. Sam can push his branches and Nora can review before anything reaches `main`. In the next chapter, two more people join — Priya (illustrator) and Kai (engineer) — and the team learns to coordinate four parallel workstreams." diff --git a/00-notes/05-distributed-git/outline.md b/00-notes/05-distributed-git/outline.md new file mode 100644 index 000000000..831e1aab6 --- /dev/null +++ b/00-notes/05-distributed-git/outline.md @@ -0,0 +1,143 @@ +# Chapter 5: Distributed Git — Section Outline + +> **Storyline phase**: Design & Build Sprint +> **Characters**: Nora, Sam, Priya (joins), Kai (joins) +> **Key event**: Four parallel workstreams; first alpha release (v0.5-alpha) + +--- + +## Section: Distributed Workflows (`distributed-workflows.asc`) +**Original**: 103 lines | **Action**: REWRITE + +### Keep +- Three workflow patterns: Centralized, Integration-Manager, Dictator/Lieutenants +- Diagrams for each workflow + +### Rewrite +- **Centralized Workflow**: "For a two-person team like Nora and Sam in the previous chapters — both push to `main` on the same repo. Simple, but doesn't scale." +- **Integration-Manager Workflow**: "Nora now acts as integration manager. Sam, Priya, and Kai each work on their own branches. Nora reviews and merges their PRs to `main`. This is the workflow most teams on GitHub use." +- **Dictator/Lieutenants**: "Used in massive projects like Material Design or Bootstrap — governance layers for design system decisions. The SketchSpark team doesn't need this, but you might encounter it when contributing to large open-source design projects." +- Add: "As a designer, you'll most likely use Integration-Manager (fork + PR) for open-source projects, or Centralized for small internal teams." + +--- + +## Section: Contributing to a Project (`contributing.asc`) +**Original**: 803 lines | **Action**: REWRITE EXAMPLES, TRIM HEAVILY + +### Commit Guidelines (lines 33-99) +**Action**: REWRITE + +- Cut `git diff --check` for whitespace — irrelevant to designers +- Replace Tim Pope commit template with SketchSpark template: + ``` + [Design: Results Screen] Add card layout with 5-option grid + + The card layout shows all 5 generated options in a responsive grid. + Each card includes a thumbnail, confidence score, and "Select" button. + Choosing a card opens the refinement view. + ``` +- Keep: "Make each commit a logically separate changeset" — reframe with: "Nora commits the product brief separately from the wireframes because they serve different review purposes." +- Cut `git add --patch` reference — save for Chapter 7 + +### Private Small Team (lines 101-325) +**Action**: REWRITE + +- Replace John/Jessica with Nora/Sam/Priya/Kai: + - Nora: UX flows and research updates (`feature/ux-flows-v2`) + - Sam: production UI screens (`feature/production-screens`) + - Priya: onboarding illustrations (`feature/onboarding-illustrations`) + - Kai: AI pipeline setup (`feature/ai-pipeline-setup`) +- Replace all file references: + - `lib/simplegit.rb` → `concept/user-flows.md` + - `TODO` → `product-brief.md` + - `index.html` → `screens/results/card-layout.fig` +- Show the fetch/merge/push coordination cycle with Nora as integrator +- Add: Priya's first push takes 3 minutes (large illustration files). Note: "We'll address large file management in Chapter 8." + +### Private Managed Team (lines 327-497) +**Action**: REWRITE + TRIM + +- Replace `featureA`/`featureB` with: + - `feature/sketch-input-redesign` (Nora + Sam) + - `feature/ai-pipeline-v1` (Kai) +- Reframe: "Ideal when your team splits into workstreams — one pair working on the input experience, another building the generation pipeline." +- Trim detail — keep the coordination pattern, cut repetitive fetch/merge sequences + +### Forked Public Project (lines 499-636) +**Action**: LIGHT REWRITE + +- Preview for Chapter 6: "This workflow appears when SketchSpark goes public. External contributors fork the repo, make changes, and submit PRs." +- Reframe `--squash`: "Collapses all experimental changes into one clean commit — like flattening your iteration layers before presenting a final design." +- Replace file examples with SketchSpark prompt template improvement + +### Public Project over Email (lines 638-791) +**Action**: REPLACE WITH NOTE + +- Replace 153 lines of email workflow with: + > "This section describes an older contribution workflow using email patches. Modern design teams use GitHub or GitLab pull requests instead. If you're contributing to a project that requires email patches, refer to the original Pro Git book for detailed instructions." +- ~5 lines (down from 153) + +--- + +## Section: Maintaining a Project (`maintaining.asc`) +**Original**: 557 lines | **Action**: REWRITE EXAMPLES, TRIM + +### Working in Topic Branches (lines 8-29) +**Action**: REWRITE +- Replace `sc/ruby_client` with `priya/icon-overhaul`, `kai/generation-speed` +- Add: "Unlike code, design changes often span multiple file types — an illustration update might include PNGs, an SVG, and a documentation update. Keep related changes in one branch." + +### Applying Patches from Email (lines 31-182) +**Action**: REPLACE WITH NOTE +- Replace 151 lines with: "Most design projects use GitHub/GitLab pull requests. If you need to apply patches from email, see the original Pro Git reference." +- ~3 lines (down from 151) + +### Checking Out Remote Branches (lines 184-218) +**Action**: LIGHT REWRITE +- Replace generic contributor with: "Priya sends you a link to her `feature/onboarding-illustrations` branch. You want to review her illustrations locally." + +### Determining What Is Introduced (lines 220-294) +**Action**: REWRITE +- Replace generic diffs with: "You want to see exactly what screens Sam designed that aren't in `main` yet." +- Show `git log main..feature/production-screens --oneline` +- Show `git diff main...feature/production-screens -- screens/` + +### Integrating Contributed Work (lines 296-402) +**Action**: REWRITE + TRIM +- **Merging Workflows**: Nora's integration pattern — review PR, merge to `main`, tag milestones +- **Large-Merging Workflows**: Label as "advanced — for massive projects, not typical product teams" +- **Cherry-Picking**: Sam cherry-picks the "pinch-to-zoom" interaction from `option/canvas-freeform` into a new feature branch (callback to Chapter 3) +- **Rerere**: Trim to concept + 3-line summary — "Git can remember how you resolved a conflict and apply the same resolution automatically next time." + +### Tagging Releases (lines 428-482) +**Action**: REWRITE +- SketchSpark `v0.5-alpha`: + ``` + git tag -a v0.5-alpha -m "Alpha: end-to-end sketch-to-options pipeline working" + ``` +- Simplify PGP signing to 1 line: "Optional. For open-source projects, signed tags add credibility." + +### Preparing a Release (lines 505-528) +**Action**: REWRITE +- ``` + git archive main --prefix='sketchspark-v0.5-alpha/' --format=zip > sketchspark-v0.5-alpha.zip + ``` +- "The archive goes to the CEO for demo day." + +### The Shortlog (lines 531-557) +**Action**: REWRITE +- Show SketchSpark shortlog: + ``` + Nora (4): Updated user flows, Added round 2 interview findings, ... + Sam (6): Added card layout screens, Fixed upload error state, ... + Priya (3): Added onboarding illustrations, ... + Kai (5): Set up AI pipeline, Added generation prompts, ... + ``` + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "The alpha works. Four team members coordinated their work through branches, pull requests, and an integration-manager workflow. Priya's large files are a growing concern. The next chapter takes SketchSpark public — and the team learns how open-source contribution works from the receiving end." diff --git a/00-notes/06-github/outline.md b/00-notes/06-github/outline.md new file mode 100644 index 000000000..5b73ead1c --- /dev/null +++ b/00-notes/06-github/outline.md @@ -0,0 +1,134 @@ +# Chapter 6: GitHub — Section Outline + +> **Storyline phase**: Public Beta & Community +> **Characters**: Nora, Sam, Priya, Kai, Marcus (external contributor) +> **Key event**: SketchSpark goes public; Marcus contributes improved mobile prompt via PR + +--- + +## Section: Account Setup and Configuration (`1-setting-up-account.asc`) +**Original**: 97 lines | **Action**: REWRITE EXAMPLES + +### Keep +- Account creation, SSH key upload, avatar, email settings +- Two-factor authentication + +### Rewrite +- Add SSH analogy: "Like a trusted device — once registered, no re-authentication needed." +- Add 2FA context: "Prevents a compromised password from putting all your team's design assets at risk." +- Replace email linking example: "If you use work and personal accounts, link both emails so GitHub tracks your total contribution history across both." + +--- + +## Section: Contributing to a Project (`2-contributing.asc`) +**Original**: 548 lines | **Action**: REWRITE + +### Forking (lines 5-26) +- Replace fork explanation with: "Forking is like duplicating a shared project to your own workspace. You can experiment freely without affecting the original." + +### GitHub Flow / Creating a PR (lines 29-195) +**Action**: FULL REWRITE — this is the chapter's centerpiece +- Replace Arduino blink example with Marcus's contribution to SketchSpark: + 1. Marcus forks `sketchspark/sketchspark` to `marcus/sketchspark` + 2. Creates `feature/mobile-prompt-template` + 3. Edits `prompts/sketch-to-ui.txt` to add mobile-specific layout constraints + 4. Adds new file: `prompts/mobile-layout.txt` + 5. Commits, pushes, opens PR + 6. PR description includes before/after screenshots: 5 generated options from the same sketch, current vs. improved prompt. Mobile options show better touch target sizing. +- Walk through the PR interface with design-relevant content + +### Iterating on a PR (lines 147-205) +**Action**: REWRITE +- Nora reviews Marcus's PR the next morning (different timezone — 16 hours apart) +- Feedback: prompt format doesn't match template, mobile-layout file needs a header comment, suggests splitting touch-target constraint for readability +- Marcus pushes updates. Nora approves and merges. +- Key point: "You don't need changes to be 'perfect' before opening a PR. Opening early lets your team weigh in on direction — just like sharing a rough sketch for feedback." + +### Advanced Pull Requests (lines 206-296) +**Action**: TRIM +- Keep cross-reference and PR-on-PR concepts +- Cut detail on keeping up with upstream — simplify to: `git fetch upstream && git merge upstream/main` + +### GitHub Flavored Markdown (lines 298-486) +**Action**: KEEP + EXPAND IMAGES +- Keep task lists, code blocks, tables, emoji — all useful for PR descriptions +- **Expand image embedding** (currently 10 lines): "Drag-and-drop screenshots into PR comments for design reviews. Include before/after comparisons, annotate with arrows or highlights, show responsive behavior at different breakpoints." +- Add: "For design PRs, screenshots aren't optional — they're the primary review artifact. Every PR that changes visual output should include them." + +### Keeping Forks in Sync (lines 488-548) +**Action**: LIGHT REWRITE +- Frame as: "Marcus keeps his fork synced so his next contribution starts from the latest version." + +--- + +## Section: Maintaining a Project (`3-maintaining.asc`) +**Original**: 377 lines | **Action**: REWRITE EXAMPLES + +### Keep +- Repository creation, README, CONTRIBUTING, LICENSE +- Branch protection +- Collaborator management + +### Rewrite +- **CONTRIBUTING.md**: Replace generic example with SketchSpark guidelines: + - Prompt template format (system context → user instruction → constraints) + - Illustration specs (2x resolution, brand palette, PNG with transparent background) + - Icon specs (24x24 grid, 2px stroke, SVG format) + - Screen mockups must include light and dark mode + - All UI must pass WCAG AA contrast +- **README**: Expand for design project: + - Product screenshot/GIF showing sketch-to-options flow + - Repository structure overview + - Quick start guide + - Link to live docs (GitHub Pages) +- **Branch protection**: Nora configures: PRs required, 1 approval, status checks +- **Labels**: `prompt-improvement`, `new-screen`, `bug`, `accessibility`, `breaking-change` + +### New +- Add "GitHub Pages for Design Documentation" subsection: + - Team deploys product docs to `sketchspark.github.io` + - Setup walkthrough (enable Pages, point to `/docs` folder or `gh-pages` branch) + +--- + +## Section: Managing an Organization (`4-managing-organization.asc`) +**Original**: 72 lines | **Action**: REWRITE EXAMPLES + +### Keep +- Organization creation, teams, permissions + +### Rewrite +- Frame with SketchSpark org: + - `@core-team`: Nora, Sam, Priya, Kai (write access to all repos) + - `@contributors`: Marcus and other external designers (fork-and-PR) + - `@stakeholders`: CEO, investors (read-only, comment on PRs) +- "If your product has 3+ contributors, an organization makes access management simpler than adding individual collaborators." + +--- + +## Section: Scripting GitHub (`5-scripting.asc`) +**Original**: 301 lines | **Action**: REWRITE + TRIM + +### Keep +- Webhooks concept +- API basics +- Practical automation examples + +### Rewrite +- Replace generic webhook with SketchSpark example: "When someone opens a PR, automatically post to `#design-reviews` in Slack." +- **GitHub Actions** (replace outdated Services section): + - "Actions let you automate validation when PRs are opened." + - SketchSpark example: validate that prompt templates don't exceed token limits, check SVG files for missing `<title>` elements +- Simplify API section: "Most automation tasks are easier via GitHub Actions than manual API calls. Use the API when Actions can't do what you need." + +### Cut +- Services section (deprecated, replaced by Actions/webhooks) +- Detailed API pagination examples — keep one simple example + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "SketchSpark is public. The team receives and reviews external contributions, maintains clear guidelines for contributors, and uses GitHub's tools to manage the growing community. Marcus improved the mobile generation from Melbourne without ever meeting the team. In the next chapter, the product enters production — and the team encounters the complexity that comes with real users and real deadlines." diff --git a/00-notes/07-git-tools/outline.md b/00-notes/07-git-tools/outline.md new file mode 100644 index 000000000..0b101ec68 --- /dev/null +++ b/00-notes/07-git-tools/outline.md @@ -0,0 +1,157 @@ +# Chapter 7: Git Tools — Section Outline + +> **Storyline phase**: Production Hardening +> **Characters**: Nora, Sam, Priya, Kai +> **Key event**: Stashing, blame, interactive staging, rebase cleanup, submodules + +--- + +## Structural Note + +Chapter 7 is the largest chapter (15 sections, 38 walkthroughs). Several sections have very low design relevance. The outline groups them by priority tier and recommends cuts. + +--- + +## TIER 1: Full Rewrite (High design relevance) + +### Section: Stashing and Cleaning (`stashing-cleaning.asc`) +**Original**: 294 lines | **Action**: REWRITE + +- **Stash scenario**: Sam is redesigning the results comparison screen (adding overlay diff mode). Tablet layout bug reported. Sam stashes: + ``` + git stash push -m "WIP: overlay diff mode for results comparison" + ``` + Fixes tablet bug on `fix/onboarding-tablet-layout`, merges, returns: + ``` + git checkout feature/overlay-diff + git stash pop + ``` +- Replace `index.html`/`lib/simplegit.rb` with `screens/results/overlay-diff.fig`, `concept/user-flows.md` +- Keep `git stash list`, `git stash apply`, `git stash drop` +- Expand branch-from-stash: "Perfect when you start work on `main` and realize it should be a feature branch." +- **Clean**: Add warning — "If design exports were untracked, `git clean` removes them permanently. Use `git clean -n` (dry run) first." + +### Section: Advanced Merging (`advanced-merging.asc`) +**Original**: 682 lines | **Action**: REWRITE + TRIM + +- Replace `hello.rb` with `design-tokens.json` merge conflict (Nora changed color values, Sam changed typography values in the same file) +- Keep three-tree analogy, reframe: "Your version (working directory), the last shared version (HEAD), the incoming version (their branch)" +- Keep `--ours`/`--theirs` strategies — frame as: "For binary files that can't merge, choose one version: `git checkout --ours illustrations/hero.png`" +- Cut `dos2unix` preprocessing, `diff3` attribute detail +- Trim to ~350 lines + +### Section: Submodules (`submodules.asc`) +**Original**: 1039 lines | **Action**: REWRITE + TRIM HEAVILY + +- **Frame**: Kai's AI pipeline repo (`sketchspark-ml`) is a submodule of the main product repo +- Keep: adding a submodule, cloning with submodules, updating submodule pointer +- Rewrite all examples with `sketchspark-ml` as the submodule +- Cut: publishing submodule changes, submodule foreach, submodule merge/rebase (advanced — link to reference) +- Target: ~300 lines (down from 1039) + +--- + +## TIER 2: Rewrite Examples (Medium relevance) + +### Section: Reset Demystified (`reset.asc`) +**Original**: 331 lines | **Action**: REWRITE + +- Redesign three-tree metaphor for designers: + - HEAD = last committed snapshot ("the version you shipped") + - Index/Staging = next commit in preparation ("what you're about to ship") + - Working Directory = current state of files ("your live canvas") +- Replace `file.txt` with `design-tokens.json` +- **Sam's mistake**: commits to `main` instead of feature branch: + ``` + git reset --soft HEAD~1 # undo commit, keep changes staged + git checkout -b feature/screen-redesign + git commit -m "Redesign generation progress screen" + ``` +- Keep `--soft`, `--mixed`, `--hard` explanation with clear warnings +- **Squashing via reset**: Priya squashes messy icon commits (add/fix/fix again) into one clean commit + +### Section: Rewriting History (`rewriting-history.asc`) +**Original**: 402 lines | **Action**: REWRITE + TRIM + +- **Amend**: Nora commits product brief update but forgot to include the updated persona: + ``` + git add research/personas/early-adopter.md + git commit --amend + ``` +- **Interactive rebase**: Priya cleans up 5 icon commits into 2 clean ones before opening PR +- **Split**: Sam's commit touches both token changes and screen layout — split for separate review +- Add prominent warning: "Never rewrite history that's been pushed and shared with teammates." +- Cut `filter-branch` entirely — replaced by `git filter-repo` (mention as 1-line note for accidental large file commits) +- Target: ~250 lines (down from 402) + +### Section: Interactive Staging (`interactive-staging.asc`) +**Original**: 204 lines | **Action**: REWRITE + +- Replace file names with `product-brief.md`, `design-tokens.json` +- **Nora's scenario**: `product-brief.md` has both a scope change (adding tablet support) and research findings update. She stages only the research hunks for the current PR: + ``` + git add -p product-brief.md + ``` +- Keep patch mode explanation (`y/n/s/e`) +- Note: "This works for text files only. Binary files (PNGs, Figma exports) can't be partially staged." + +### Section: Searching (`searching.asc`) +**Original**: 160 lines | **Action**: REWRITE EXAMPLES + +- `git grep "primary-blue"` — find all files referencing a specific color token +- `git log -S "5 options" -- product-brief.md` — find when the product concept changed +- `git log -L :generateOptions:pipeline/main.py` — Kai traces function history +- Frame as "more relevant for design system maintainers and leads than individual contributors" + +### Section: Debugging (`debugging.asc`) +**Original**: 149 lines | **Action**: REWRITE EXAMPLES + +- **Blame**: Priya uses `git blame design-tokens.json` to find who changed `primary-blue` and when +- Since it's a text file, blame shows line-by-line attribution — "Commit `a1b2c3d` by Sam, 3 days ago, changed `primary-blue` from `#1a73e8` to `#1f71e8`" +- **Bisect**: Mark as optional/advanced — "If you're maintaining a large project and a visual regression appeared somewhere in the last 50 commits, bisect helps you find the exact commit. Otherwise, skip this." + +--- + +## TIER 3: Trim or Cut (Low relevance) + +### Section: Revision Selection (`revision-selection.asc`) +**Original**: 401 lines | **Action**: TRIM TO ~100 LINES +- Keep: short SHA references, branch references, `HEAD~` and `HEAD^` syntax +- Keep: commit ranges (`main..feature/screens`) +- Cut: detailed reflog walkthrough (save for Ch10), `@{upstream}` syntax detail, ancestry detail +- Frame ranges with: "See what Sam added that's not in main yet: `git log main..feature/production-screens`" + +### Section: Credentials (`credentials.asc`) +**Original**: 203 lines | **Action**: TRIM TO ~50 LINES +- Keep: cache, store, osxkeychain overview +- Cut: custom credential helpers, detailed implementation +- Frame: "If Git keeps asking for your password, configure a credential helper." + +### Section: Rerere (`rerere.asc`) +**Original**: 255 lines | **Action**: TRIM TO ~30 LINES +- Concept + enable command: `git config --global rerere.enabled true` +- "Git remembers how you resolved a conflict and applies the same resolution next time." + +### Section: Signing (`signing.asc`) +**Original**: 204 lines | **Action**: TRIM TO ~10 LINES +- "If your organization requires signed commits for compliance, configure GPG here. Most product teams don't use this." + +### Section: Bundling (`bundling.asc`) +**Original**: 171 lines | **Action**: CUT +- Move to appendix or remove. Designers don't transfer repos offline. + +### Section: Replace (`replace.asc`) +**Original**: 211 lines | **Action**: CUT +- Too advanced. No design team use case. + +### Section: Subtree Merges (`subtree-merges.asc`) +**Original**: 103 lines | **Action**: CUT +- Submodules section covers the relevant use case. Subtree merging is an alternative most teams won't need. + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "The team has the tools to handle real-world complexity — stashing interrupted work, cleaning up messy history, resolving merge conflicts in token files, and managing the AI pipeline as a submodule. In the next chapter, they encode their process into the repository itself: Git attributes for binary files, commit templates, and validation hooks." diff --git a/00-notes/08-customizing-git/outline.md b/00-notes/08-customizing-git/outline.md new file mode 100644 index 000000000..35e93b379 --- /dev/null +++ b/00-notes/08-customizing-git/outline.md @@ -0,0 +1,136 @@ +# Chapter 8: Customizing Git — Section Outline + +> **Storyline phase**: Process & Automation +> **Characters**: Nora, Sam, Priya, Kai +> **Key event**: `.gitattributes` for binary files, commit template, pre-commit hooks + +--- + +## Section: Git Configuration (`config.asc`) +**Original**: 517 lines | **Action**: REWRITE + TRIM + +### Keep +- External merge/diff tools (visual comparison — intuitive for designers) +- Commit templates +- Color configuration +- `core.editor` setting + +### Rewrite +- **Commit template**: Replace `[Ticket: X]` with SketchSpark template: + ``` + [Phase: Component] Short description + + # Phases: Research, Concept, Design, Pipeline, Docs, Fix, Release + ``` + Show `git config commit.template .gitmessage` +- **Diff tool**: Expand with `design-tokens.json` diff example — show how visual diff tools make JSON changes easier to review +- **Color**: "Designers naturally understand color configuration — customize Git's terminal output to match your preferences." + +### Cut +- `core.autocrlf` and `core.whitespace` — irrelevant to designers working with design files +- Server-side config — designers don't administer servers +- Detailed pager/diff algorithm config + +### Target +- ~250 lines (down from 517) + +--- + +## Section: Git Attributes (`attributes.asc`) +**Original**: 377 lines | **Action**: REWRITE — THIS IS THE CHAPTER'S CENTERPIECE + +### Keep +- Binary file identification +- Custom diff drivers +- Export-ignore +- Merge strategies per file + +### Rewrite +- **Binary file handling**: Replace generic examples with SketchSpark's `.gitattributes`: + ``` + # Binary — don't attempt to diff or merge + *.png binary + *.psd binary + *.fig binary + *.sketch binary + + # Text-based design files — diff normally + *.svg diff + *.md diff + *.json diff + *.yaml diff + + # Large source files — version but exclude from archives + *.psd export-ignore + *.sketch export-ignore + research/raw-interviews/ export-ignore + ``` +- **Image diffing**: Nora sets up EXIF-based diffing for PNG exports — `git diff` shows metadata changes (dimensions, color profile, DPI). "It's not a visual diff, but it catches the color profile mistake that cost Priya time in Chapter 7." +- **Export-ignore**: "Priya's `.psd` source files are versioned in Git (for backup and history) but excluded from release archives. Stakeholders get clean exports, not 100MB Photoshop files." +- **Merge strategy**: "For binary design files, set `merge=ours` — if two people modify the same illustration, Git keeps your version and flags the conflict rather than producing a corrupted merge." + +### Cut +- C code indentation filter — replace with design-relevant filter concept: "A filter could auto-optimize SVGs on checkout or transform design tokens from JSON to CSS variables." +- Complex Ruby keyword expansion + +### New +- Add complete `.gitattributes` template for design projects with comments explaining each rule + +--- + +## Section: Git Hooks (`hooks.asc`) +**Original**: 131 lines | **Action**: REWRITE + +### Keep +- Hook lifecycle (client-side vs. server-side) +- pre-commit, commit-msg, post-commit + +### Rewrite +- Front-load the hooks designers will use: + 1. **pre-commit**: "Validate `model-params.yaml` syntax before committing. Check that prompt templates don't exceed 4096 tokens. Warn if PNG files exceed 5MB." + 2. **commit-msg**: "Validate that commit messages match `[Phase: Component]` pattern. Reject `fix stuff` with a helpful error." + 3. **post-commit**: "Trigger a design system build or Slack notification after each commit." +- De-emphasize email hooks (`applypatch-msg`, `pre-applypatch`) — designers never use `git am` +- Add: "Hooks are shell scripts in `.git/hooks/`. They run automatically. If a pre-commit hook fails, the commit is blocked until you fix the issue." + +### New +- Provide copy-paste hook scripts — designers can't write Ruby/Perl from scratch: + - YAML validation pre-commit hook (5 lines of bash) + - Commit message format validation (10 lines of bash) + - File size warning (5 lines of bash) + +--- + +## Section: An Example Git-Enforced Policy (`policy.asc`) +**Original**: 443 lines | **Action**: REWRITE + TRIM HEAVILY + +### Keep +- Concept of policy enforcement through hooks +- Client-side hook testing walkthrough + +### Rewrite +- Replace full Ruby scripts with simpler shell scripts +- Replace `[ref: XXXX]` pattern with `[Phase: Component]` pattern +- **ACL example**: Reframe for SketchSpark: + - Nora: edit anything + - Sam: edit `screens/`, `design-tokens.json`, `concept/` + - Priya: edit `illustrations/`, `icons/` + - Kai: edit `pipeline/`, `model-params.yaml` + - "This prevents accidentally committing to someone else's area." +- Emphasize client-side hooks over server-side — designers care about local validation +- Add testing scenario: "Sam tries to commit with message `fix stuff`. The hook rejects it and shows the expected format." + +### Cut +- Dense Ruby ACL implementation — replace with pseudo-code + explanation +- Server-side update hook detail (designers don't manage server hooks) + +### Target +- ~150 lines (down from 443) + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "The team's process is now encoded in the repository. `.gitattributes` tells Git how to handle binary files. The commit template enforces consistent messages. Hooks validate files before they're committed. New contributors (like Marcus from Chapter 6) inherit these rules automatically when they clone. In the next chapter, the team faces an unexpected challenge: migrating a competitor's design assets from an older version control system." diff --git a/00-notes/09-git-and-other-scms/outline.md b/00-notes/09-git-and-other-scms/outline.md new file mode 100644 index 000000000..2d14a6f98 --- /dev/null +++ b/00-notes/09-git-and-other-scms/outline.md @@ -0,0 +1,90 @@ +# Chapter 9: Git and Other Systems — Section Outline + +> **Storyline phase**: Legacy Migration +> **Characters**: Nora, Priya +> **Key event**: Acquiring QuickMock competitor; migrating 3 years of SVN design assets + +--- + +## Structural Change: Drastically Trim + +This chapter drops from 7 sections (2,298 lines) to 3 focused sections. Most VCS bridge content is irrelevant to designers. The migration storyline justifies the content that remains. + +--- + +## Section: Git as a Client — Subversion (`client-svn.asc`) +**Original**: 490 lines | **Action**: TRIM TO ~120 LINES + +### Keep +- `git svn clone` basics +- `git svn dcommit` and `git svn rebase` workflow +- Branching limitations when bridging + +### Rewrite +- Frame: "QuickMock's design assets have lived in SVN for 3 years. During the transition period, the SketchSpark team needs to work with both systems." +- Replace generic branch examples with: `redesign/components`, `feature/new-icons` +- Add context: "SVN is the most likely legacy system you'll encounter in enterprise design environments — large companies sometimes keep design archives in SVN." + +### Cut +- SVN Style History detail +- SVN Annotation +- Detailed branching/merging mechanics (designers won't need SVN branching) +- Pre-rebase hook detail + +--- + +## Section: Importing from Subversion (`import-svn.asc`) +**Original**: 144 lines | **Action**: REWRITE + +### Keep +- `git svn clone` for full import +- Author mapping with `authors.txt` +- Post-import cleanup + +### Rewrite +- **Pre-import planning**: Nora audits QuickMock's SVN repo: + - 2,400 files, 1.2GB total + - Bulk of size: PSD source files (some >100MB) and high-res marketing renders + - Text files (research notes, docs): small and numerous +- **Decisions**: + - Import full history for text files — the evolution matters + - Import latest version only for large binaries — old 100MB PSDs aren't useful enough to justify bloat + - Configure Git LFS for files >10MB going forward + - Map QuickMock's flat folder structure to SketchSpark's organized hierarchy +- **Author mapping**: Map SVN usernames to Git identities so QuickMock's team gets proper attribution +- **Post-cleanup**: SVN `@` suffixes, LFS migration, folder reorganization +- Add: `git lfs migrate import --include="*.psd,*.ai" --above=10mb` +- Priya's observation: "I wish we'd set up LFS from the start." + +### New +- Add "Pre-Migration Checklist" sidebar: + 1. Check total repo size + 2. Identify files >10MB for LFS + 3. Create author mapping file + 4. Plan target folder structure + 5. Decide: full history or latest snapshot for binaries? + +--- + +## Sections: Everything Else +**Action**: REPLACE WITH NOTES + +### Git and Mercurial (`client-hg.asc`, `import-hg.asc`) +**Original**: 520 lines combined | **Action**: REPLACE WITH 3-LINE NOTE +- "Mercurial is rarely used in design workflows. If you need to migrate from Mercurial, see the original Pro Git reference." + +### Git and Perforce (`client-p4.asc`, `import-p4.asc`) +**Original**: 773 lines combined | **Action**: REPLACE WITH 5-LINE NOTE +- "Perforce is used in some enterprise environments, particularly game studios and organizations with large binary assets. If your design assets are in Perforce, the migration approach is similar to SVN: assess size, plan LFS, map authors. See the original Pro Git reference for detailed instructions." + +### Custom Importer (`import-custom.asc`) +**Original**: 371 lines | **Action**: REPLACE WITH 5-LINE NOTE +- "If your team versioned designs as dated folders (`backup_2023_01_15/components.sketch`), Git's fast-import tool can convert that history into proper Git commits. This is a specialized task — see the original Pro Git reference or ask your engineering team for help." + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "The QuickMock migration took a day. Three years of design evolution is now searchable alongside SketchSpark's history. The combined repo is 800MB with LFS. The team learned to plan migrations carefully — size audits, LFS configuration, and author mapping make the difference between a clean import and a bloated mess. In the next chapter, a near-disaster teaches the team why Git's internals matter." diff --git a/00-notes/10-git-internals/outline.md b/00-notes/10-git-internals/outline.md new file mode 100644 index 000000000..480321d61 --- /dev/null +++ b/00-notes/10-git-internals/outline.md @@ -0,0 +1,153 @@ +# Chapter 10: Git Internals — Section Outline + +> **Storyline phase**: Scale & Recovery +> **Characters**: Nora, Sam +> **Key event**: Sam force-resets `main` before launch; Nora recovers via reflog + +--- + +## Section: Plumbing and Porcelain (`plumbing-porcelain.asc`) +**Original**: 37 lines | **Action**: REWRITE + +### Rewrite +- Open with the incident: "Two days before SketchSpark's v1.0 launch, Sam accidentally runs `git reset --hard HEAD~3` on `main`. Three days of work disappear — Nora's release notes, Priya's final marketing illustrations, Kai's generation speed improvement." +- Then: "To understand why the work isn't actually gone, you need to understand how Git stores data. This chapter looks under the hood — not to teach you to build Git, but to give you confidence that your work is safe." +- Frame plumbing vs. porcelain: "Everything you've done so far — commit, push, merge — is porcelain. The plumbing underneath is what makes recovery possible." + +--- + +## Section: Git Objects (`objects.asc`) +**Original**: 437 lines | **Action**: REWRITE + TRIM HEAVILY + +### Keep +- Three object types: blob, tree, commit +- Concept of content-addressable storage +- How commits chain together + +### Rewrite +- Replace "content-addressable filesystem" with: "Every file version gets a unique fingerprint based on its exact content. If the same icon appears in two branches, Git stores it once." +- Replace `test.txt` examples with SketchSpark files: + - Blob = the contents of `product-brief.md` at a specific moment + - Tree = the `screens/results/` directory listing at a specific moment + - Commit = a snapshot of the entire project, plus who made it and why +- **Nora explains to Sam**: "When you committed those release notes, Git created objects for every file. When you reset `main`, Git didn't delete those objects — it just moved the `main` pointer to an older commit. The objects are still in the database." + +### Cut +- Ruby SHA-1 object creation walkthrough — zero design relevance +- Low-level `git cat-file` details — keep one example showing a commit object +- Manual tree creation with `git update-index` / `git write-tree` + +### Target +- ~150 lines (down from 437) + +--- + +## Section: Git References (`refs.asc`) +**Original**: 209 lines | **Action**: REWRITE + +### Keep +- Branches as pointers to commits +- HEAD as pointer to current branch +- Tags as permanent pointers +- Remote references + +### Rewrite +- "Branches are just labels pointing to commits — like sticky notes on a timeline. Moving them — even destructively — doesn't destroy the commits they pointed to." +- "When Sam ran `reset --hard`, he moved the `main` sticky note backward. The commits it used to point to are still there, just no longer reachable through `main`." +- Tags: "`v0.5-alpha` is a permanent label. Unlike branches, tags don't move. They're anchors in your project history." +- Simplify HEAD to: "HEAD is 'where you are now.' It usually points to a branch name, which points to a commit." + +--- + +## Section: Packfiles (`packfiles.asc`) +**Original**: 163 lines | **Action**: REWRITE + +### Rewrite +- Open: "Priya notices `git push` takes 90 seconds. The repo has grown — thousands of files across months of work." +- Explain: "Git packs similar objects together using delta compression. When Priya commits a slightly modified illustration, Git stores one complete version plus a compact diff — not two full copies." +- But: "Very large binary files (her 50MB PSDs) resist delta compression. That's why Git LFS exists — it stores large files outside the main object database." +- Simplify `git gc`: "Git does this automatically. You don't need to run it manually." +- Replace `repo.rb` example with `design-tokens.json` and `illustrations/onboarding/step-1.png` + +--- + +## Section: Maintenance and Data Recovery (`maintenance.asc`) +**Original**: 353 lines | **Action**: REWRITE — THIS IS THE CHAPTER'S CLIMAX + +### Keep +- Reflog walkthrough +- `git fsck` for deeper recovery +- Auto-gc concept + +### Rewrite +- **Reflog recovery** — the centerpiece: + ``` + git reflog + ``` + Nora sees every position HEAD has been in. Three entries up: the commit before Sam's reset. + ``` + git branch recovery a1b2c3d + git checkout recovery + git log --oneline -5 + ``` + All three commits are there. Merge recovery into main. +- Frame: "Git's reflog keeps a record of every label movement for at least 30 days. Even if Sam had deleted the branch, the reflog would still know where it pointed." +- **fsck**: "If the reflog is empty (rare — requires manual deletion), `git fsck --full` finds dangling commits. Create a branch from one to recover." +- **Large object removal**: Simplify to concept + alternatives: `.gitignore` prevention, Git LFS, `git filter-repo` for cleanup. Link to detailed reference. + +### New +- Add "Best Practices for Preventing Data Loss" sidebar: + 1. Commit frequently (committed work is safe; uncommitted isn't) + 2. Never use `--hard` on shared branches + 3. Push regularly (remote is a second backup) + 4. Use branch protection to prevent accidental force-pushes to `main` + +--- + +## Section: The Refspec (`refspec.asc`) +**Original**: 145 lines | **Action**: TRIM TO ~40 LINES + +### Keep +- Basic refspec concept +- Selective fetching + +### Rewrite +- "Refspecs define which branches you fetch. Useful if your project has 20 branches and you only need `main` and `feature/screens`." +- One example, then link to reference for details + +### Cut +- Pushing refspecs detail +- Deleting references via refspec + +--- + +## Section: Transfer Protocols (`transfer-protocols.asc`) +**Original**: 292 lines | **Action**: TRIM TO ~30 LINES + +### Rewrite +- Replace protocol mechanics with practical troubleshooting: + - "Why does `git clone` fail?" → check URL, SSH keys, network + - "Why does push hang?" → large files, network timeout + - "SSH vs. HTTPS?" → SSH for regular contributors, HTTPS for occasional +- Add: "Most designers can skip this section. Return here if you're troubleshooting a connection problem." + +--- + +## Section: Environment Variables (`environment.asc`) +**Original**: 237 lines | **Action**: TRIM TO ~30 LINES + +### Keep +- `GIT_EDITOR` (which editor opens for commit messages) +- `GIT_TRACE` (debugging — "my clone/push hangs") +- `GIT_SSH_COMMAND` (custom SSH key) + +### Cut +- Everything else — pathspecs, advanced networking, internal variables + +--- + +## Chapter Summary +**Action**: REWRITE + +### New +- "Sam's mistake and Nora's recovery bookend the journey. In Chapter 1, Nora lost work because she *didn't* use version control. In Chapter 10, Sam nearly lost work despite using it — but Git's design made recovery straightforward. The reflog, immutable objects, and reference labels form a safety net that protects months of research, design, and configuration. Your work is never truly lost." diff --git a/00-notes/A-git-in-other-environments/outline.md b/00-notes/A-git-in-other-environments/outline.md new file mode 100644 index 000000000..73ee9020d --- /dev/null +++ b/00-notes/A-git-in-other-environments/outline.md @@ -0,0 +1,92 @@ +# Appendix A: Git in Other Environments — Section Outline + +> **Storyline phase**: Tooling Choices +> **Characters**: Nora (CLI), Sam (VS Code), Priya (GitHub Desktop), Kai (JetBrains) +> **Key event**: Team never agreed on one tool — each uses what fits their workflow + +--- + +## Structural Change: Add Decision Tree Opening + +### New Section: "Choosing Your Git Interface" +Add at the start (~20 lines): +- "There is no single best Git tool. Each SketchSpark team member uses something different." +- Decision tree: + - "I mainly write text files (research, docs, tokens)" → CLI or VS Code + - "I work with lots of image files and large binaries" → GitHub Desktop + - "I write code alongside design work" → VS Code or JetBrains + - "I want the simplest possible interface" → GitHub Desktop + - "I want maximum control" → CLI +- "No choice is wrong. The best Git tool is the one you'll actually use." + +--- + +## Section: Graphical Interfaces (`guis.asc`) +**Original**: 151 lines | **Action**: REWRITE + +### Keep +- gitk and git-gui mention (for reference) +- Third-party client overview concept + +### Rewrite +- Lead with the three tools the team actually uses: GitHub Desktop, VS Code Git panel, GitKraken +- Add: "When to use Git vs. cloud design tools" — Figma's version history handles Figma files; Git handles everything else (tokens, docs, research, exports, configs) +- Add `.gitignore` reminder: "GUI tools still require `.gitignore` — they just provide a friendlier way to stage and commit." +- Replace generic client list with curated recommendations for designers + +--- + +## Section: Visual Studio Code (`visualstudiocode.asc`) +**Original**: 22 lines | **Action**: EXPAND + +### Rewrite +- Expand to ~50 lines — VS Code is Sam's primary tool +- "Sam edits `design-tokens.json` and `user-flows.md` with inline gutter indicators showing what changed since last commit." +- Highlight: Source Control panel, inline diff, staging individual hunks via UI, GitHub PR extension for reviewing Marcus's contributions +- Add: "VS Code's Git integration covers 90% of daily design workflow. You'll need the CLI for advanced operations (rebase, bisect, reflog)." +- Note limitation: "Binary files (PNGs, Figma exports) show as 'changed' but can't display visual diffs in VS Code." + +--- + +## Section: JetBrains IDEs (`jetbrainsides.asc`) +**Original**: 11 lines | **Action**: LIGHT EXPAND + +### Rewrite +- Frame for Kai: "WebStorm integrates Git into the development workflow — commit, push, merge conflicts, and log are accessible without leaving the editor." +- Add: Version Control ToolWindow, three-pane merge conflict resolution +- ~20 lines (up from 11) + +--- + +## Section: Sublime Text (`sublimetext.asc`) +**Original**: 16 lines | **Action**: KEEP, ADD NOTE + +### Add +- "If you use Sublime Text, its Git integration is solid. For most designers, VS Code or GitHub Desktop will be more intuitive." + +--- + +## Sections: Shell Configuration (Bash, Zsh, PowerShell) +**Original**: 184 lines combined | **Action**: TRIM + +### Bash (`bash.asc`, 43 lines) → TRIM TO ~20 LINES +- Keep: prompt showing current branch (safety check — "prevents committing to wrong branch") +- Cut: detailed `\w`, `\$` syntax — link to reference + +### Zsh (`zsh.asc`, 55 lines) → TRIM TO ~25 LINES +- Note: Zsh is macOS default post-Catalina +- Recommend oh-my-zsh as beginner-friendly path +- Cut: manual `vcs_info` configuration detail + +### PowerShell (`powershell.asc`, 86 lines) → TRIM TO ~30 LINES +- Simplify posh-git installation to single command +- Cut: ExecutionPolicy scope explanation +- Add: "For Windows designers who prefer a visual tool, GitHub Desktop is a simpler alternative." + +--- + +## Appendix Summary +**Action**: ADD + +### New +- "The right tool depends on your role and comfort level. Nora's CLI mastery, Sam's VS Code workflow, Priya's GitHub Desktop staging, and Kai's JetBrains integration all accomplish the same thing — they just match different working styles. Start with whatever feels least intimidating and expand from there." diff --git a/00-notes/B-embedding-git/outline.md b/00-notes/B-embedding-git/outline.md new file mode 100644 index 000000000..7e0438f75 --- /dev/null +++ b/00-notes/B-embedding-git/outline.md @@ -0,0 +1,106 @@ +# Appendix B: Embedding Git in Your Applications — Section Outline + +> **Storyline phase**: Tool Integration +> **Characters**: Kai, Priya, Nora +> **Key event**: SketchSpark uses libgit2 internally; Priya automates exports with Dulwich + +--- + +## Structural Change: Reframe Entirely + +Replace "how to code Git integration" with "where Git integration appears in design tools and how it affects UX." + +### New Introduction (~15 lines) +> "This appendix is relevant in two scenarios: (1) you're designing applications that integrate version control, or (2) you want to understand how your design tools use Git under the hood. You don't need to write code — this is about understanding the landscape." + +### New Section Order +1. Overview: "Where Git Integration Appears in Design Tools" (NEW) +2. Libgit2 → "The Library Behind Your Tools" +3. Dulwich → "Git Automation with Python" +4. Command-Line Git → "When Tools Shell Out to Git" +5. JGit & go-git → consolidated as "Other Libraries" (brief) + +--- + +## New Section: Where Git Integration Appears +**Action**: NEW (~40 lines) + +- GitHub Desktop, GitKraken, Sublime Merge — all built on libgit2 +- Figma plugins that export to Git — use Dulwich or command-line Git +- CI/CD systems (GitHub Actions) — use command-line Git +- SketchSpark itself: Kai explains that the generation pipeline uses libgit2 to create each of the 5 generated options as a lightweight branch in a temporary repo. "The product's architecture mirrors Git's branching model — you've been using Git concepts through the UI all along." + +--- + +## Section: Libgit2 (`libgit2.asc`) +**Original**: 237 lines | **Action**: REWRITE + TRIM + +### Keep +- What libgit2 is and what it powers +- Language bindings concept (Rugged/Ruby, LibGit2Sharp/C#) +- Basic usage example + +### Rewrite +- Lead with: "Libgit2 powers GitHub Desktop, GitKraken, and Sublime Merge — the GUI tools designers actually use." +- After code example, add: "In a design tool, users never see this code. They click 'Save Version' and libgit2 creates the commit." +- Frame bindings as: "Available in every language — Ruby, Python, C#, JavaScript. If your engineering team builds internal tools, they likely use one of these." + +### Cut +- Advanced ODB backends +- Detailed binding installation instructions + +### Target +- ~80 lines (down from 237) + +--- + +## Section: Dulwich (`dulwich.asc`) +**Original**: 42 lines | **Action**: EXPAND + +### Keep +- What Dulwich is (pure Python Git) + +### Rewrite +- Frame as most designer-relevant: "Python is widely used in design automation — Figma plugins, token generation scripts, SVG optimization pipelines." +- **Priya's export script**: She wants to auto-commit illustrations whenever she exports from her design tool: + ```python + from dulwich.repo import Repo + repo = Repo(".") + repo.stage(["illustrations/onboarding/step-1-upload.png"]) + repo.do_commit(b"Auto-export: updated onboarding illustration step 1") + ``` + "Ten lines of code. Now her workflow is: export from design tool → script commits automatically → she opens a PR when the batch is ready." +- Add: "Common in: Figma plugins, design token scripts, CI/CD automation, export pipelines." + +### Target +- ~50 lines (up from 42) + +--- + +## Section: Command-Line Git (`command-line.asc`) +**Original**: 16 lines | **Action**: REWRITE + +### Rewrite +- Replace technical constraints (text parsing, process management) with UX design patterns: + - "If you're designing an application that integrates Git, users expect: version history, save/commit, undo, branch/explore, and sync/share." + - Reference existing UX patterns: GitHub Desktop's commit list, VS Code's gutter indicators, GitKraken's visual graph +- **Nora's exercise**: She sketches a "version history" panel for SketchSpark — translating Git concepts into a visual interface for non-technical designers + +--- + +## Sections: JGit and go-git +**Original**: 243 lines combined | **Action**: CONSOLIDATE + TRIM + +### Rewrite +- Combine into single "Other Libraries" section (~30 lines) +- JGit: "Java — powers Eclipse and some CI tools" +- go-git: "Go — powers CLI tools and some design token generators" +- Add: "For most design-adjacent work, Dulwich (Python) or libgit2 (multi-language) are more relevant." + +--- + +## Appendix Summary +**Action**: ADD + +### New +- "The tools you use every day — GitHub Desktop, VS Code, Figma plugins — are built on these libraries. Understanding that they exist demystifies how those tools work and opens the door to simple automation, like Priya's export script. You don't need to become a programmer — you just need to know what's possible." diff --git a/00-notes/C-git-commands/outline.md b/00-notes/C-git-commands/outline.md new file mode 100644 index 000000000..55c4487a4 --- /dev/null +++ b/00-notes/C-git-commands/outline.md @@ -0,0 +1,96 @@ +# Appendix C: Git Commands — Section Outline + +> **Storyline phase**: Reference +> **Characters**: All (referenced by chapter) +> **Key event**: Workflow-based reorganization of command reference + +--- + +## Structural Change: Reorganize by Workflow + +Replace the current taxonomy-based organization (Setup, Snapshotting, Branching, Sharing, Inspection, Debugging, Patching, Email, External, Admin, Plumbing) with workflow-based grouping that mirrors how the SketchSpark team actually uses Git. + +--- + +## New Structure + +### 1. Starting a Project (~30 lines) +- `git init` — Create a new repository (Nora, Ch2) +- `git clone` — Copy an existing repository (Sam joining, Ch3) +- `git config` — Set your name, email, editor, commit template (Ch1, Ch8) + +### 2. Daily Design Work (~60 lines) +- `git status` — What's changed since my last commit? +- `git add` — Select files to include in the next commit +- `git add -p` — Select specific changes within a file (Nora, Ch7) +- `git commit` — Save a checkpoint with a message +- `git diff` — What exactly changed? (text files: detailed; binary: limited) +- `git stash` — Set aside work-in-progress temporarily (Sam, Ch7) +- `git rm` — Remove a file from tracking +- `git mv` — Rename or move a tracked file + +### 3. Exploring & Branching (~50 lines) +- `git branch` — List, create, or delete branches +- `git checkout` / `git switch` — Move to a different branch +- `git merge` — Combine one branch into another +- `git rebase` — Replay commits onto a different base (Sam, Ch3) +- `git cherry-pick` — Copy a single commit to another branch (Ch5) + +### 4. Collaborating (~50 lines) +- `git remote` — Manage connections to shared repositories +- `git push` — Send your commits to the shared repository +- `git pull` — Download and merge teammates' changes +- `git fetch` — Download without merging (check first, merge later) +- `git submodule` — Manage nested repositories (Kai's pipeline, Ch7) + +### 5. Reviewing History (~40 lines) +- `git log` — See commit history (use `--oneline --graph` for visual overview) +- `git log -S "keyword"` — Find when a specific term was added or removed +- `git show` — Display a specific commit's contents +- `git blame` — Find who last changed each line (Priya, Ch7) +- `git diff` (between branches) — Compare two branches side by side + +### 6. Shipping a Release (~25 lines) +- `git tag` — Mark a commit as a release (v0.1-concept, v0.5-alpha, v1.0) +- `git archive` — Create a distributable zip/tar without Git history +- `git describe` — Generate a version string from the nearest tag + +### 7. Fixing Mistakes (~40 lines) +- `git restore` — Discard uncommitted changes to a file +- `git restore --staged` — Unstage a file without losing changes +- `git reset --soft HEAD~1` — Undo the last commit, keep changes staged (Sam, Ch7) +- `git reset --mixed HEAD~1` — Undo the last commit, unstage changes +- `git revert` — Create a new commit that undoes a previous commit (safe for shared branches) +- `git reflog` — Find lost commits after a destructive operation (Nora, Ch10) +- `git clean` — Remove untracked files (caution: irreversible) + +### 8. Managing Large Files (~15 lines) +- `git lfs install` — Enable Git LFS in a repository +- `git lfs track "*.psd"` — Track large files with LFS +- `git lfs migrate` — Move existing large files to LFS storage +- Note: "Essential for design projects with illustrations, PSDs, or high-res exports >10MB." + +--- + +## Sections to Cut + +| Original Section | Lines | Action | +|-----------------|-------|--------| +| Email (am, apply, format-patch, send-email, request-pull, imap-send) | ~48 | DELETE — "Modern teams use GitHub/GitLab Pull Requests. See Chapter 6." | +| External Systems (svn, fast-import) | ~16 | DELETE — "See Chapter 9 if migrating from SVN." | +| Plumbing (ls-files, ls-remote, rev-parse) | ~12 | DELETE — "For advanced internals, see Chapter 10." | +| Administration (filter-branch, fsck, reflog, gc) | ~20 | MOVE reflog to "Fixing Mistakes"; delete rest or link to Ch10 | + +## Format Changes + +- Each command includes: 1-line description + chapter reference where it appears in the storyline +- Commands link back to their chapter so readers can revisit the full context +- Add relevance indicator: **Essential** (use daily), **Important** (use weekly), **Advanced** (use occasionally) + +--- + +## Estimated Impact +- Cut ~80 lines of irrelevant content (email, external, plumbing) +- Add ~15 lines (LFS section) +- Reorganize remaining ~350 lines into workflow groups +- Net: ~285 lines, significantly more navigable From 12e6080e2e95778309a06816014f9ad0a84cf976 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sun, 5 Apr 2026 01:32:11 +0000 Subject: [PATCH 14/18] Move initial revision notes to archive directory with README Pre-storyline analysis files relocated from per-chapter directories to 00-notes/initial-revision-notes/. README explains their context, why they were superseded, and their relationship to the current outline.md files. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- .../01-introduction.md} | 0 .../02-git-basics.md} | 0 .../03-git-branching.md} | 0 .../04-git-server.md} | 0 .../05-distributed-git.md} | 0 .../06-github.md} | 0 .../07-git-tools.md} | 0 .../08-customizing-git.md} | 0 .../09-git-and-other-scms.md} | 0 .../10-git-internals.md} | 0 .../A-git-in-other-environments.md} | 0 .../B-embedding-git.md} | 0 .../C-git-commands.md} | 0 00-notes/initial-revision-notes/README.md | 41 +++++++++++++++++++ 14 files changed, 41 insertions(+) rename 00-notes/{01-introduction/ux-designer-revision-notes.md => initial-revision-notes/01-introduction.md} (100%) rename 00-notes/{02-git-basics/ux-designer-revision-notes.md => initial-revision-notes/02-git-basics.md} (100%) rename 00-notes/{03-git-branching/ux-designer-revision-notes.md => initial-revision-notes/03-git-branching.md} (100%) rename 00-notes/{04-git-server/ux-designer-revision-notes.md => initial-revision-notes/04-git-server.md} (100%) rename 00-notes/{05-distributed-git/ux-designer-revision-notes.md => initial-revision-notes/05-distributed-git.md} (100%) rename 00-notes/{06-github/ux-designer-revision-notes.md => initial-revision-notes/06-github.md} (100%) rename 00-notes/{07-git-tools/ux-designer-revision-notes.md => initial-revision-notes/07-git-tools.md} (100%) rename 00-notes/{08-customizing-git/ux-designer-revision-notes.md => initial-revision-notes/08-customizing-git.md} (100%) rename 00-notes/{09-git-and-other-scms/ux-designer-revision-notes.md => initial-revision-notes/09-git-and-other-scms.md} (100%) rename 00-notes/{10-git-internals/ux-designer-revision-notes.md => initial-revision-notes/10-git-internals.md} (100%) rename 00-notes/{A-git-in-other-environments/ux-designer-revision-notes.md => initial-revision-notes/A-git-in-other-environments.md} (100%) rename 00-notes/{B-embedding-git/ux-designer-revision-notes.md => initial-revision-notes/B-embedding-git.md} (100%) rename 00-notes/{C-git-commands/ux-designer-revision-notes.md => initial-revision-notes/C-git-commands.md} (100%) create mode 100644 00-notes/initial-revision-notes/README.md diff --git a/00-notes/01-introduction/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/01-introduction.md similarity index 100% rename from 00-notes/01-introduction/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/01-introduction.md diff --git a/00-notes/02-git-basics/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/02-git-basics.md similarity index 100% rename from 00-notes/02-git-basics/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/02-git-basics.md diff --git a/00-notes/03-git-branching/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/03-git-branching.md similarity index 100% rename from 00-notes/03-git-branching/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/03-git-branching.md diff --git a/00-notes/04-git-server/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/04-git-server.md similarity index 100% rename from 00-notes/04-git-server/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/04-git-server.md diff --git a/00-notes/05-distributed-git/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/05-distributed-git.md similarity index 100% rename from 00-notes/05-distributed-git/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/05-distributed-git.md diff --git a/00-notes/06-github/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/06-github.md similarity index 100% rename from 00-notes/06-github/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/06-github.md diff --git a/00-notes/07-git-tools/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/07-git-tools.md similarity index 100% rename from 00-notes/07-git-tools/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/07-git-tools.md diff --git a/00-notes/08-customizing-git/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/08-customizing-git.md similarity index 100% rename from 00-notes/08-customizing-git/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/08-customizing-git.md diff --git a/00-notes/09-git-and-other-scms/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/09-git-and-other-scms.md similarity index 100% rename from 00-notes/09-git-and-other-scms/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/09-git-and-other-scms.md diff --git a/00-notes/10-git-internals/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/10-git-internals.md similarity index 100% rename from 00-notes/10-git-internals/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/10-git-internals.md diff --git a/00-notes/A-git-in-other-environments/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/A-git-in-other-environments.md similarity index 100% rename from 00-notes/A-git-in-other-environments/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/A-git-in-other-environments.md diff --git a/00-notes/B-embedding-git/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/B-embedding-git.md similarity index 100% rename from 00-notes/B-embedding-git/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/B-embedding-git.md diff --git a/00-notes/C-git-commands/ux-designer-revision-notes.md b/00-notes/initial-revision-notes/C-git-commands.md similarity index 100% rename from 00-notes/C-git-commands/ux-designer-revision-notes.md rename to 00-notes/initial-revision-notes/C-git-commands.md diff --git a/00-notes/initial-revision-notes/README.md b/00-notes/initial-revision-notes/README.md new file mode 100644 index 000000000..19ef39e2d --- /dev/null +++ b/00-notes/initial-revision-notes/README.md @@ -0,0 +1,41 @@ +# Initial Revision Notes + +These 13 files are the first-pass analysis of how each Pro Git chapter could be adapted for UX designers learning Git. They were generated by deploying parallel agents to read the original AsciiDoc source files and the walkthrough catalogs, then compiling recommendations per chapter. + +## Context + +- **Created**: Early in the project, before the SketchSpark product storyline existed +- **Purpose**: Identify what resonates, what confuses, and what's missing for a UX designer audience in each chapter +- **Scope**: Section-by-section priority ratings, design tool analogies (Figma, Sketch, Adobe XD), content gaps, and structural recommendations + +## Why They Were Superseded + +These notes recommend generic design adaptations — "replace with design system example," "add Figma analogy," "use design token scenario" — without a unifying product, team, or narrative thread. They are useful as raw analysis but don't specify *which* product, *which* characters, or *which* artifacts to use. + +The project subsequently developed: + +1. **`storyline.md`** — A complete narrative following "SketchSpark" (an AI-powered rapid prototyping tool) from research through launch, with four named characters and a defined repository structure +2. **`storyline-analysis.md`** — A mapping of how the storyline applies to each chapter's revision recommendations +3. **Per-chapter `outline.md` files** — Section-by-section outlines specifying what stays, what's rewritten, and what's new, using SketchSpark examples throughout + +## Files + +| File | Original Location | Content | +|------|-------------------|---------| +| `01-introduction.md` | `00-notes/01-introduction/` | Version control concepts, Git fundamentals, installation | +| `02-git-basics.md` | `00-notes/02-git-basics/` | Daily workflow: init, clone, status, add, commit, diff, log | +| `03-git-branching.md` | `00-notes/03-git-branching/` | Branching, merging, rebasing, remote branches | +| `04-git-server.md` | `00-notes/04-git-server/` | Hosting, protocols, SSH, GitLab | +| `05-distributed-git.md` | `00-notes/05-distributed-git/` | Workflows, contributing, maintaining projects | +| `06-github.md` | `00-notes/06-github/` | Account setup, PRs, organizations, scripting | +| `07-git-tools.md` | `00-notes/07-git-tools/` | Stashing, reset, submodules, searching, debugging | +| `08-customizing-git.md` | `00-notes/08-customizing-git/` | Configuration, attributes, hooks, policy | +| `09-git-and-other-scms.md` | `00-notes/09-git-and-other-scms/` | SVN/Mercurial/Perforce bridges and migration | +| `10-git-internals.md` | `00-notes/10-git-internals/` | Objects, references, packfiles, recovery | +| `A-git-in-other-environments.md` | `00-notes/A-git-in-other-environments/` | GUIs, IDEs, shell configuration | +| `B-embedding-git.md` | `00-notes/B-embedding-git/` | Libgit2, JGit, Dulwich, go-git | +| `C-git-commands.md` | `00-notes/C-git-commands/` | Command reference reorganization | + +## Status + +**Archived.** These files are retained as historical context. The per-chapter `outline.md` files are the current working documents for the adaptation. From 4d3464c84b8dbc1c9382068a46bfea7e494cd097 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sun, 5 Apr 2026 01:43:56 +0000 Subject: [PATCH 15/18] Add full SketchSpark product specification Defines the product concept, core interaction model, screen inventory, AI generation pipeline, prompt templates, design tokens, user roles, technical stack, milestones, and competitive landscape. https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- 00-notes/sketchspark-product-spec.md | 298 +++++++++++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 00-notes/sketchspark-product-spec.md diff --git a/00-notes/sketchspark-product-spec.md b/00-notes/sketchspark-product-spec.md new file mode 100644 index 000000000..075d9a515 --- /dev/null +++ b/00-notes/sketchspark-product-spec.md @@ -0,0 +1,298 @@ +# SketchSpark — Product Specification + +## What Is SketchSpark? + +SketchSpark is an AI-powered rapid prototyping application that turns rough sketches into polished UI designs. A designer provides a single input — a napkin wireframe, a whiteboard photo, a tablet drawing, or a simple digital sketch — and SketchSpark generates up to five distinct, high-fidelity UI options in parallel. The designer reviews, compares, selects a direction, and refines it iteratively until the design is ready for development handoff. + +--- + +## The Problem + +The gap between idea and testable prototype is the slowest part of the design process. A designer has a concept — maybe sketched on paper during a meeting, maybe roughed out on a tablet on the train home — and turning that into something a team can evaluate takes hours or days. Wireframing tools require manual construction of every element. High-fidelity mockup tools demand pixel-level precision before anything looks real enough to test. + +Meanwhile, the best design decisions come from comparing options. Research consistently shows that teams who evaluate multiple directions produce stronger outcomes than teams who refine a single idea. But generating multiple polished directions multiplies the time cost — so in practice, most teams explore one direction and hope it's the right one. + +SketchSpark eliminates this tradeoff. + +--- + +## Core Interaction Model + +### Input +The designer provides a rough sketch through one of three input methods: + +1. **Upload**: Photograph of a hand-drawn sketch (napkin, whiteboard, notebook), uploaded as JPEG or PNG +2. **Draw**: Freehand sketch drawn directly in the SketchSpark canvas using a mouse, trackpad, or stylus +3. **Import**: Existing low-fidelity wireframe imported from Figma, Sketch, or as SVG/PNG + +The sketch does not need to be precise. SketchSpark interprets intent: a rectangle becomes a card, a circle becomes an avatar, a squiggle with lines becomes a text block, an arrow becomes navigation. The AI model is trained to read rough spatial relationships and structural patterns, not pixel-perfect drawings. + +### Processing +SketchSpark analyzes the sketch and generates up to five UI interpretations simultaneously. Each option: + +- Applies a different layout strategy (grid, list, asymmetric, card-based, editorial) +- Respects the spatial relationships in the original sketch +- Uses the project's design tokens (colors, typography, spacing) if configured +- Follows platform conventions (iOS, Android, or web) based on project settings +- Meets WCAG AA accessibility standards by default (contrast, touch targets, font sizes) + +Generation takes 15–45 seconds depending on sketch complexity and selected platform. + +### Output +The results screen presents all generated options in a side-by-side comparison view. For each option, the designer sees: + +- A full-fidelity screen mockup at the target resolution +- A confidence score (how closely the option matches the sketch's intent) +- Layout strategy label (e.g., "Card Grid," "Editorial Stack," "Split Panel") +- Quick annotations highlighting key interpretation decisions + +The designer can: + +- **Select** an option to use as the starting point for refinement +- **Compare** two options in an overlay diff view (superimposed at 50% opacity) +- **Regenerate** a single option with adjusted parameters (e.g., "more whitespace," "larger typography") +- **Refine** the selected option in an integrated editor with AI-assisted adjustments +- **Export** any option as Figma file, SVG, PNG, or development-ready code (HTML/CSS or React components) + +### Iteration +After selecting a direction, the designer enters the refinement loop: + +1. Adjust the selected design (move elements, change hierarchy, update content) +2. Ask SketchSpark to regenerate variations of the adjusted design +3. Compare, select, adjust again +4. Repeat until satisfied + +Each iteration takes seconds, not hours. The designer maintains creative control — SketchSpark generates options, the designer makes decisions. + +--- + +## Product Architecture + +### Core Screens + +| Screen | Purpose | Key Interactions | +|--------|---------|------------------| +| **Home / Dashboard** | Project list, recent sketches, quick-start | Create new project, open recent, view history | +| **Sketch Input** | Upload, draw, or import the source sketch | Drag-and-drop upload, freehand canvas, file picker, Figma import | +| **Generation Progress** | Loading state during AI processing | Progress indicator, cancel button, "What's happening" explainer | +| **Results Comparison** | Side-by-side view of 5 generated options | Select, compare overlay, regenerate single, expand detail | +| **Refinement Editor** | Edit selected option with AI assistance | Direct manipulation, AI regeneration of subsections, token application | +| **Export** | Output to design tools or development formats | Figma, Sketch, SVG, PNG, HTML/CSS, React components | +| **History** | Version timeline of all generations and refinements | Browse, restore, branch from any point | +| **Settings** | Project configuration | Platform target, design tokens, team preferences, API keys | +| **Onboarding** | First-run experience for new users | 3-step tutorial: upload → generate → refine | + +### Platform Targets +SketchSpark generates designs for three platforms: + +- **Web** (responsive: desktop 1440px, tablet 768px, mobile 375px) +- **iOS** (iPhone 15 Pro, iPad Pro) +- **Android** (Pixel 8, Galaxy Tab) + +Platform selection affects layout conventions, navigation patterns, typography scales, and touch target sizes. A single sketch can generate options for multiple platforms simultaneously. + +### Design Token Integration +Projects can define design tokens (via `design-tokens.json`) that constrain generation: + +```json +{ + "colors": { + "primary": "#2563EB", + "secondary": "#7C3AED", + "surface": "#FFFFFF", + "on-surface": "#1E293B", + "error": "#DC2626", + "success": "#16A34A" + }, + "typography": { + "heading-1": { "family": "Inter", "weight": 700, "size": "32px", "line-height": 1.2 }, + "heading-2": { "family": "Inter", "weight": 600, "size": "24px", "line-height": 1.3 }, + "body": { "family": "Inter", "weight": 400, "size": "16px", "line-height": 1.5 }, + "caption": { "family": "Inter", "weight": 400, "size": "12px", "line-height": 1.4 } + }, + "spacing": { + "xs": "4px", + "sm": "8px", + "md": "16px", + "lg": "24px", + "xl": "32px", + "2xl": "48px" + }, + "border-radius": { + "sm": "4px", + "md": "8px", + "lg": "16px", + "full": "9999px" + } +} +``` + +When tokens are configured, all generated options use them — ensuring brand consistency across every variation. When tokens are absent, SketchSpark applies sensible defaults. + +--- + +## AI Generation Pipeline + +### Sketch Interpretation +The input sketch passes through a vision model that identifies: + +- **Elements**: rectangles (cards, containers), circles (avatars, icons), lines (dividers, borders), text blocks, arrows (navigation, flow), images (placeholders) +- **Hierarchy**: relative size indicates importance; vertical position indicates reading order +- **Grouping**: proximity and alignment suggest related elements +- **Intent patterns**: recognized UI conventions (tab bar, header, list, form, modal) + +### Option Generation +Each of the five options is generated by the same base model with different layout strategy parameters: + +| Option | Strategy | Characteristics | +|--------|----------|-----------------| +| Option 1 | **Faithful** | Closest interpretation of the sketch's literal layout | +| Option 2 | **Grid** | Elements reorganized into a structured grid system | +| Option 3 | **Editorial** | Asymmetric, magazine-style layout with visual hierarchy emphasis | +| Option 4 | **Minimal** | Maximum whitespace, reduced elements, focus on core content | +| Option 5 | **Dense** | Information-rich, compact layout maximizing content density | + +The strategies are configurable. Teams can replace defaults or add custom strategies via prompt templates (`prompts/sketch-to-ui.txt`, `prompts/mobile-layout.txt`). + +### Prompt Templates +The generation pipeline uses text-based prompt templates that define how the model interprets and renders sketches: + +``` +# prompts/sketch-to-ui.txt +# Core generation prompt for SketchSpark + +## System Context +You are a UI design generator. Given a sketch analysis (element positions, +hierarchy, grouping, intent patterns), generate a high-fidelity UI mockup. + +## Constraints +- Apply design tokens if provided; use system defaults otherwise +- Meet WCAG AA contrast ratios (4.5:1 for body text, 3:1 for large text) +- Touch targets minimum 44x44px for mobile, 24x24px for web +- Respect platform conventions for navigation, typography, and spacing + +## Layout Strategy: {strategy_name} +{strategy_description} + +## Output +Render as structured layout definition with element positions, styles, +and content. Include accessibility labels for all interactive elements. +``` + +These templates are plain text files — fully version-controllable, diffable, and improvable via pull requests (as Marcus demonstrates in Chapter 6). + +### Accessibility +Every generated option includes: + +- WCAG AA contrast compliance (checked automatically, violations flagged) +- Semantic structure (headings, landmarks, reading order) +- Touch target sizing per platform guidelines +- Alt text suggestions for image placeholders +- Focus order and keyboard navigation hints + +An optional post-generation accessibility audit (`prompts/accessibility-check.txt`) runs a second pass and annotates the design with specific compliance notes. + +### Model Configuration +The AI model's behavior is controlled through `model-params.yaml`: + +```yaml +model: + version: "sketchspark-v3.2" + inference: + temperature: 0.7 # Higher = more creative variation between options + max_tokens: 8192 + timeout_seconds: 45 + generation: + num_options: 5 # 1-5 parallel options + min_confidence: 0.6 # Don't show options below this confidence + platform: "web" # web | ios | android + responsive_breakpoints: + - 1440 + - 768 + - 375 + quality: + accessibility_level: "AA" # AA | AAA + contrast_check: true + touch_target_check: true +``` + +This file is structured YAML — Git can diff it, hooks can validate it, and changes are traceable through commit history. + +--- + +## User Roles and Workflows + +### Solo Designer (Freelancer) +- Uploads client sketches, generates options, presents 3–5 directions to the client +- Uses SketchSpark to compress the "sketch to mockup" phase from 2 days to 2 hours +- Exports directly to Figma for final polish and handoff + +### Design Team (3–8 people) +- Shared project with design tokens enforcing brand consistency +- Multiple designers generate options for different screens simultaneously +- Results comparison view used in team critiques — "let's look at everyone's options for the checkout flow" +- History view tracks who generated what and which directions were chosen + +### Design-Engineering Handoff +- Selected designs export as development-ready code (HTML/CSS or React components) +- Design tokens ensure generated code uses the same spacing, colors, and typography as the design +- Engineers consume tokens from `design-tokens.json` in their build system +- Version history provides context: "why does this screen look this way?" → trace back to the original sketch and the option selection decision + +--- + +## Technical Stack (for repository context) + +| Layer | Technology | Repository Artifacts | +|-------|-----------|---------------------| +| Frontend | React + TypeScript | `src/` (not in design repo) | +| Design | Figma (source), PNG/SVG (exports) | `screens/`, `illustrations/`, `icons/` | +| AI Pipeline | Python + PyTorch | `pipeline/`, `model-params.yaml`, `prompts/` | +| Design Tokens | JSON (consumed by both design and engineering) | `design-tokens.json` | +| Documentation | Markdown | `docs/`, `product-brief.md`, `research/` | +| CI/CD | GitHub Actions | `.github/workflows/` | + +The design repository (the one tracked in the book's storyline) contains everything except the frontend source code. This is intentional — the repo is a designer's workspace, not an engineering monorepo. + +--- + +## Product Milestones (as referenced in the storyline) + +| Tag | Milestone | What's Working | +|-----|-----------|----------------| +| `v0.1-concept` | Concept approved | Product brief, personas, competitive analysis, initial user flows, wireframes | +| `v0.5-alpha` | Internal alpha | End-to-end pipeline: upload sketch → generate 5 options → view comparison. Single platform (web). Default tokens only. | +| `v0.8-beta` | Public beta | All three input methods. Web + iOS platforms. Design token integration. Export to Figma and PNG. Onboarding flow. GitHub public repo. | +| `v1.0` | Public launch | All platforms. Refinement editor. Code export. Accessibility audit. Team collaboration features. Mobile prompt improvements (Marcus's contribution). QuickMock migration complete. | + +--- + +## Competitive Landscape + +| Competitor | What It Does | How SketchSpark Differs | +|-----------|-------------|------------------------| +| **Figma** | Collaborative design tool | Figma is the canvas; SketchSpark is the idea accelerator. Exports *to* Figma. | +| **Uizard** | AI screen generation from text prompts | Text-to-UI vs. sketch-to-UI. SketchSpark preserves the designer's spatial intent. | +| **Galileo AI** | AI UI generation from text descriptions | Similar AI approach but text-driven. SketchSpark starts from visual input. | +| **Framer** | Design + publish tool with AI features | Framer focuses on shipping websites. SketchSpark focuses on the exploration phase. | +| **Midjourney / DALL-E** | General image generation | Produces images, not structured UI. Can't export to Figma or generate code. No accessibility checking. | + +SketchSpark's differentiator: **parallel options from spatial input**. The designer's sketch encodes intent that text prompts can't — relative sizing, spatial grouping, reading order. Five options from one sketch means the designer explores more of the solution space in less time than any competitor allows. + +--- + +## Why This Product Works as a Book Example + +SketchSpark is designed to serve double duty as a compelling product *and* an effective Git teaching vehicle: + +1. **Parallel generation mirrors branching.** Five options from one sketch is the same mental model as five branches from one commit. The product's core concept reinforces Git's most important feature. + +2. **Full design lifecycle.** Research → concept → exploration → build → beta → launch → scale. Every phase produces different artifact types (text, binary, structured config) that teach different Git workflows. + +3. **Mixed file types.** Research briefs (merge-friendly markdown), screen mockups (binary Figma exports), AI prompts (diffable text), illustrations (large binary PNGs), tokens (structured JSON). This variety naturally teaches Git's strengths and limitations. + +4. **Team growth.** Solo (Ch1–2) → pair (Ch3) → small team (Ch5) → open source (Ch6). Each growth stage demands the exact Git workflow that chapter teaches. + +5. **AI pipeline.** Model configs, prompt templates, and training manifests are text files that benefit from version control, validation hooks, and code review — making chapters on hooks, attributes, and collaboration feel immediately relevant rather than abstract. + +6. **Real product decisions.** "Should we use card layout or list layout?" is a design decision readers can visualize. It's more engaging than "should we use tabs or spaces?" — and it naturally becomes a branch, a PR, and a merge. From 4205beb18d5f36f8f9a7ed06d833a9e26e99cf3c Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Wed, 8 Apr 2026 11:46:39 +0000 Subject: [PATCH 16/18] Move ToC files into chapter directories; remove obsolete storyline files - 13 toc-*.md files moved from 00-notes/ root into their respective chapter directories as toc.md - Removed storyline-analysis.md (superseded by per-chapter outlines) - Removed storyline-rewrite-task.md (completed task doc) https://claude.ai/code/session_011MhF8iWLG3rS5jturtiTZ5 --- .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../{toc-ch06-github.md => 06-github/toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 .../toc.md} | 0 00-notes/storyline-analysis.md | 258 ------------------ 00-notes/storyline-rewrite-task.md | 29 -- 15 files changed, 287 deletions(-) rename 00-notes/{toc-ch01-getting-started.md => 01-introduction/toc.md} (100%) rename 00-notes/{toc-ch02-git-basics.md => 02-git-basics/toc.md} (100%) rename 00-notes/{toc-ch03-git-branching.md => 03-git-branching/toc.md} (100%) rename 00-notes/{toc-ch04-git-on-the-server.md => 04-git-server/toc.md} (100%) rename 00-notes/{toc-ch05-distributed-git.md => 05-distributed-git/toc.md} (100%) rename 00-notes/{toc-ch06-github.md => 06-github/toc.md} (100%) rename 00-notes/{toc-ch07-git-tools.md => 07-git-tools/toc.md} (100%) rename 00-notes/{toc-ch08-customizing-git.md => 08-customizing-git/toc.md} (100%) rename 00-notes/{toc-ch09-git-and-other-systems.md => 09-git-and-other-scms/toc.md} (100%) rename 00-notes/{toc-ch10-git-internals.md => 10-git-internals/toc.md} (100%) rename 00-notes/{toc-appendix-a-git-in-other-environments.md => A-git-in-other-environments/toc.md} (100%) rename 00-notes/{toc-appendix-b-embedding-git.md => B-embedding-git/toc.md} (100%) rename 00-notes/{toc-appendix-c-git-commands.md => C-git-commands/toc.md} (100%) delete mode 100644 00-notes/storyline-analysis.md delete mode 100644 00-notes/storyline-rewrite-task.md diff --git a/00-notes/toc-ch01-getting-started.md b/00-notes/01-introduction/toc.md similarity index 100% rename from 00-notes/toc-ch01-getting-started.md rename to 00-notes/01-introduction/toc.md diff --git a/00-notes/toc-ch02-git-basics.md b/00-notes/02-git-basics/toc.md similarity index 100% rename from 00-notes/toc-ch02-git-basics.md rename to 00-notes/02-git-basics/toc.md diff --git a/00-notes/toc-ch03-git-branching.md b/00-notes/03-git-branching/toc.md similarity index 100% rename from 00-notes/toc-ch03-git-branching.md rename to 00-notes/03-git-branching/toc.md diff --git a/00-notes/toc-ch04-git-on-the-server.md b/00-notes/04-git-server/toc.md similarity index 100% rename from 00-notes/toc-ch04-git-on-the-server.md rename to 00-notes/04-git-server/toc.md diff --git a/00-notes/toc-ch05-distributed-git.md b/00-notes/05-distributed-git/toc.md similarity index 100% rename from 00-notes/toc-ch05-distributed-git.md rename to 00-notes/05-distributed-git/toc.md diff --git a/00-notes/toc-ch06-github.md b/00-notes/06-github/toc.md similarity index 100% rename from 00-notes/toc-ch06-github.md rename to 00-notes/06-github/toc.md diff --git a/00-notes/toc-ch07-git-tools.md b/00-notes/07-git-tools/toc.md similarity index 100% rename from 00-notes/toc-ch07-git-tools.md rename to 00-notes/07-git-tools/toc.md diff --git a/00-notes/toc-ch08-customizing-git.md b/00-notes/08-customizing-git/toc.md similarity index 100% rename from 00-notes/toc-ch08-customizing-git.md rename to 00-notes/08-customizing-git/toc.md diff --git a/00-notes/toc-ch09-git-and-other-systems.md b/00-notes/09-git-and-other-scms/toc.md similarity index 100% rename from 00-notes/toc-ch09-git-and-other-systems.md rename to 00-notes/09-git-and-other-scms/toc.md diff --git a/00-notes/toc-ch10-git-internals.md b/00-notes/10-git-internals/toc.md similarity index 100% rename from 00-notes/toc-ch10-git-internals.md rename to 00-notes/10-git-internals/toc.md diff --git a/00-notes/toc-appendix-a-git-in-other-environments.md b/00-notes/A-git-in-other-environments/toc.md similarity index 100% rename from 00-notes/toc-appendix-a-git-in-other-environments.md rename to 00-notes/A-git-in-other-environments/toc.md diff --git a/00-notes/toc-appendix-b-embedding-git.md b/00-notes/B-embedding-git/toc.md similarity index 100% rename from 00-notes/toc-appendix-b-embedding-git.md rename to 00-notes/B-embedding-git/toc.md diff --git a/00-notes/toc-appendix-c-git-commands.md b/00-notes/C-git-commands/toc.md similarity index 100% rename from 00-notes/toc-appendix-c-git-commands.md rename to 00-notes/C-git-commands/toc.md diff --git a/00-notes/storyline-analysis.md b/00-notes/storyline-analysis.md deleted file mode 100644 index cb63e31f1..000000000 --- a/00-notes/storyline-analysis.md +++ /dev/null @@ -1,258 +0,0 @@ -# Common Storyline Analysis - -## Problem: Fragmented Examples Across Chapters - -The current revision notes propose disconnected examples across chapters: - -- **Inconsistent characters**: Sarah (Ch5), Marcus (Ch5), Aisha (Ch5), Maria (Ch6), Megan (Ch5 branch name only) — none carry between chapters -- **Disconnected artifacts**: button components, checkout flows, form components, icon sets, and design tokens appear repeatedly but without continuity -- **No progression**: each chapter reinvents its scenario from scratch, so readers never build on prior context - -A unified storyline solves all three problems. Readers follow one product, one team, and one set of artifacts from Chapter 1 through Chapter 10, with each chapter advancing the story naturally. - ---- - -## Proposed Storyline: "SketchSpark" — AI-Powered Rapid Prototyping - -### The Product -SketchSpark is an AI-powered rapid prototyping application. A designer uploads or draws a rough sketch, and the system generates up to 5 polished UI options in parallel. The designer reviews, selects, and refines a direction — then iterates toward a shippable product. - -### Why This Product -- **Parallel generation mirrors Git branching**: 5 options from 1 sketch = 5 branches from 1 commit. The core metaphor is baked into the product itself. -- **Full design lifecycle**: research (user interviews, competitive analysis), concept design (sketches, information architecture), UI design (wireframes, mockups), visual design (high-fidelity screens, motion), development, testing, launch, iteration — every phase produces distinct artifacts that need version control. -- **Rich artifact variety**: research briefs, persona documents, journey maps, wireframes, AI model configuration files, prompt templates, training data manifests, screen mockups, icon sets, motion specs, design tokens, and production assets — a mix of text (Git-friendly) and binary (Git-challenged) files that naturally teaches both workflows. -- **AI component adds modern relevance**: model configs (`model-params.yaml`), prompt templates (`prompts/sketch-to-ui.txt`), and generation pipelines are text files that merge cleanly — contrasting with binary mockup files that don't. -- **Accessible domain**: every designer understands "sketch to prototype" — no industry-specific jargon required. - -### The Team - -| Character | Role | Personality Trait | Introduced | -|-----------|------|-------------------|------------| -| **Nora** | UX Lead / Product Owner | Methodical researcher, sets standards, writes the briefs | Ch1 | -| **Sam** | UI/Visual Designer | Fast mover, generates options quickly, sometimes commits messy | Ch2 | -| **Priya** | Concept Designer / Illustrator | Works with large binary files (sketches, illustrations, journey maps) | Ch3 | -| **Kai** | Frontend Engineer / ML Integration | Bridges design and code, maintains AI pipeline configs | Ch5 | - -Each character's working style naturally triggers specific Git scenarios: -- **Nora's** research documents and briefs are text-heavy — perfect for diffs and merges -- **Sam's** speed creates stash/reset/amend situations — he commits too fast, forgets files, works on wrong branches -- **Priya's** illustrations and high-fidelity mockups are large binaries — triggers LFS, attributes, and binary merge challenges -- **Kai's** model configs and pipeline files are structured text — demonstrates cross-functional collaboration and submodules - -### The Product Timeline - -Each chapter picks up where the prior left off, following SketchSpark from idea to shipped product: - -| Chapter | Product Phase | What Happens | -|---------|---------------|--------------| -| **Ch1** | Research & Discovery | Nora loses a week of user research notes when her "interview-notes-FINAL-v3" folder gets overwritten by a sync conflict. She discovers Git. Installs it. Learns what version control means through the lens of protecting research artifacts. | -| **Ch2** | Concept Design | Nora creates the SketchSpark repo. Adds the product brief (`product-brief.md`), early wireframes, competitive analysis, and persona documents. Learns status, add, commit, diff, log. Creates `.gitignore` for design tool temp files. First tag: `v0.1-concept`. | -| **Ch3** | Parallel Exploration | Sam joins to explore UI directions. The core product idea — 5 options from 1 sketch — plays out in their workflow: Sam creates 3 branches (`option/card-layout`, `option/list-layout`, `option/canvas-freeform`) to explore different approaches to the results screen. Nora continues refining the input sketch flow on `main`. Their first merge conflict: both edited `user-flows.md`. | -| **Ch4** | Team Infrastructure | The team moves from local-only to GitHub. Nora sets up the org, branch protection (no direct pushes to `main`), and team roles. They evaluate hosting options — GitHub wins over self-hosted for a startup-stage product. | -| **Ch5** | Design & Build Sprint | Priya joins for illustration and high-fidelity mockups. Kai joins to build the AI generation pipeline. Four people coordinating: Nora on UX flows, Sam on UI screens, Priya on onboarding illustrations, Kai on model configs. Integration-manager workflow. First milestone release: `v0.5-alpha` — the sketch-to-options pipeline works end to end. | -| **Ch6** | Public Beta & Community | SketchSpark launches a public beta on GitHub. External contributor (Marcus) forks the repo and submits a PR improving the prompt template for better mobile layouts. Nora reviews with annotated screenshots, requests changes, merges. The team writes CONTRIBUTING.md with guidelines for prompt templates, asset specs, and accessibility requirements. | -| **Ch7** | Production Hardening | Real-world complexity hits: Sam stashes half-finished screen designs to hotfix a broken onboarding flow. Priya uses `git blame` to find when an illustration's color palette drifted from the brand guide. Nora uses interactive rebase to clean up a messy sprint of "fix layout" / "fix layout again" / "actually fix layout" commits. Kai's AI pipeline repo becomes a submodule. | -| **Ch8** | Process & Automation | Nora configures `.gitattributes` for Priya's binary illustration files, creates a commit message template (`[Phase: Component] Description`), and adds a pre-commit hook that validates `model-params.yaml` syntax and checks that prompt templates don't exceed token limits. | -| **Ch9** | Legacy Migration | The company acquires a competitor whose design assets live in SVN. The team migrates 3 years of mockups, illustrations, and research documents into the SketchSpark repo. They handle large binaries, history cleanup, and Git LFS setup. | -| **Ch10** | Scale & Recovery | Sam accidentally force-resets `main`, losing three days of work before a launch deadline. Nora uses reflog to recover every commit. The chapter demystifies Git internals through the lens of "your work is never truly lost" — critical when months of design research, illustrations, and AI configs are at stake. | -| **App A** | Tooling Choices | Each team member uses different tools: Nora uses CLI, Sam prefers VS Code's Git panel for visual diffs of screen designs, Priya uses GitHub Desktop for large file management, Kai uses JetBrains. Decision tree based on role and comfort. | -| **App B** | Tool Integration | Kai explains how SketchSpark's own AI pipeline uses libgit2 under the hood to version-control generated options. Priya explores how Figma plugins use Dulwich (Python) to auto-export assets to Git. | -| **App C** | Reference | Quick-reference card organized by SketchSpark workflow phases: "Starting research" (init, clone), "Daily design work" (branch, add, commit, status), "Reviewing options" (diff, log, show), "Shipping a release" (tag, merge, push). | - ---- - -## Artifact Continuity Map - -These artifacts appear and evolve across chapters, giving readers anchoring reference points. - -### Core Files (appear 5+ chapters) - -| Artifact | First Appears | Evolves Through | Purpose | -|----------|---------------|-----------------|---------| -| `product-brief.md` | Ch2 (created) | Ch3 (updated with chosen direction), Ch5 (alpha scope), Ch6 (public beta scope), Ch8 (commit template references it) | The "source of truth" text file — mergeable, diffable, anchors every design decision | -| `user-flows.md` | Ch2 (initial sketch flow) | Ch3 (merge conflict — Nora and Sam both edited), Ch5 (expanded for full pipeline), Ch7 (blame to find when a flow changed) | Primary UX artifact — where merge conflicts feel real and relatable | -| `screens/results/` | Ch3 (3 layout options as branches) | Ch5 (Sam's production screens), Ch7 (stash scenario mid-redesign), Ch8 (commit template) | The heart of the product — where parallel options become parallel branches | -| `model-params.yaml` | Ch5 (Kai creates) | Ch7 (submodule), Ch8 (pre-commit validation hook), Ch10 (recovered via reflog) | Structured text config — demonstrates Git-friendly AI/ML files alongside binary design files | -| `.gitignore` | Ch2 (created) | Ch5 (expanded for build artifacts), Ch8 (expanded for design tools and model caches) | Practical file designers need immediately | - -### Secondary Files (appear 2-3 chapters) - -| Artifact | Chapters | Purpose | -|----------|----------|---------| -| `research/personas/` | Ch2 (Nora creates), Ch5 (referenced in sprint planning), Ch9 (migrated from legacy) | Text-heavy research artifacts — ideal for diffs | -| `research/competitive-analysis.md` | Ch2 (created), Ch6 (updated when going public) | Shows how research docs evolve alongside product | -| `illustrations/onboarding/` | Ch5 (Priya creates), Ch7 (blame for color drift), Ch10 (packfile performance with large PNGs) | Binary file handling — large asset management | -| `prompts/sketch-to-ui.txt` | Ch5 (Kai creates), Ch6 (Marcus improves via PR), Ch8 (token-limit validation hook) | AI prompt templates — text files that external contributors can improve | -| `CONTRIBUTING.md` | Ch6 (created for public beta), Ch8 (referenced in hooks) | Governance and standards for open contribution | -| `CHANGELOG.md` | Ch5 (v0.5-alpha), Ch7 (rewriting history to clean up entries) | Release documentation | -| `design-tokens.json` | Ch5 (Sam creates for handoff to Kai), Ch7 (selective staging — color vs. typography), Ch8 (attributes config) | Bridge between design and code — the handoff file | - -### Lifecycle Phase Artifacts - -| Product Phase | Key Artifacts | File Types | Git Behavior | -|---------------|---------------|------------|--------------| -| Research | `product-brief.md`, `personas/*.md`, `competitive-analysis.md`, `interview-notes/*.md` | Markdown, text | Fully mergeable, excellent diffs | -| Concept Design | `user-flows.md`, `information-architecture.md`, `sketches/*.png` | Mixed | Text merges cleanly; sketch PNGs are binary | -| UI Design | `screens/**/*.fig`, `screens/**/*.png`, `wireframes/*.md` | Mostly binary | Binary conflicts require manual resolution | -| Visual Design | `illustrations/**/*.png`, `icons/**/*.svg`, `design-tokens.json` | Binary + JSON | SVGs diff as text; PNGs don't; tokens merge | -| AI Pipeline | `model-params.yaml`, `prompts/*.txt`, `training-data-manifest.json` | Structured text | Fully mergeable, hookable, validatable | -| Production | `assets/exported/**`, `docs/`, `CHANGELOG.md` | Mixed | Export-ignore for source files; archive for releases | - ---- - -## Scene-by-Scene Storyline Mapping to Existing Recommendations - -### Chapter 1 — Research & Discovery - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Add concrete scenario after line 8's designer mention | Nora's "interview-notes-FINAL-v3" folder disaster — a cloud sync conflict overwrites a week of user research for the SketchSpark concept | -| CVCS = Figma shared file analogy | Nora compares her team's shared Google Drive (centralized, single point of failure) to Git (full local copy of all research history) | -| Three states = draft/ready/approved | Nora maps modified/staged/committed to her research workflow: draft notes → reviewed findings → published insight | -| Binary file support flag | Nora asks: "Can I version my sketch mockups and interview recordings?" — honest answer about binary limitations sets up a theme that runs through every chapter | - -### Chapter 2 — Concept Design - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| "Initializing a design system repository" | Nora runs `git init` in the `sketchspark/` directory after completing the concept phase | -| Replace `.c` file examples | All examples use `product-brief.md`, `research/personas/early-adopter.md`, `wireframes/sketch-input-flow.png` | -| `.gitignore` template for designers | Nora creates `.gitignore` excluding `.sketch~`, `*.figma_cache`, `__MACOSX/`, `.DS_Store`, `node_modules/` | -| Commit message conventions | Nora writes: `Add product brief and initial user flow wireframes` | -| Design token search in log | Nora uses `git log -S "single sketch"` to find when the core product concept changed from "3 options" to "5 options" in the brief | -| Tags for releases | Nora tags the concept milestone: `git tag -a v0.1-concept -m "Research complete, concept approved, entering UI exploration"` | - -### Chapter 3 — Parallel Exploration - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Branch as design variant | Sam creates `option/card-layout`, `option/list-layout`, `option/canvas-freeform` — three parallel UI directions for the results screen, mirroring SketchSpark's own "5 options from 1 sketch" philosophy | -| Hotfix interruption scenario | Sam is deep in `option/card-layout`; Nora discovers a critical user flow gap in the sketch input screen on `main` — Sam creates `fix/sketch-input-upload-error` | -| Merge conflict in token file | Both Nora and Sam edited `user-flows.md` — Nora refined the upload step, Sam added a "compare options" step. They resolve together, learning that text files merge but require coordination. | -| Branch naming conventions | Team establishes: `option/` (design explorations), `feature/` (approved work), `fix/` (corrections), `research/` (investigation branches) | -| Rebasing as "replay on cleaner foundation" | Sam rebases `option/card-layout` onto main to pick up Nora's updated user flow before the team reviews all three options side by side | - -### Chapter 4 — Team Infrastructure - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Lead with hosted options | Nora evaluates GitHub vs. GitLab for the growing team — picks GitHub for its PR review workflow and project boards | -| SSH key setup with context | Sam struggles with SSH keys — Nora walks him through it: "The `.pub` file is like a badge that proves who you are. The private file is your ID — never share it." | -| Branch protection | Nora enables `main` branch protection: PRs required, one design review approval needed before merge. No direct commits to `main`. | -| Role mapping | Nora = admin (merges to main, manages releases), Sam = write (creates branches, opens PRs), stakeholders = read-only (view progress, leave comments) | - -### Chapter 5 — Design & Build Sprint - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Three-person coordination | Nora (UX flows and research updates), Sam (production UI screens), Priya (onboarding illustrations), Kai (AI pipeline configs) — four parallel workstreams | -| Replace `lib/simplegit.rb` files | All file references: `screens/results/card-layout.fig`, `illustrations/onboarding/step-1.png`, `model-params.yaml`, `prompts/sketch-to-ui.txt` | -| Integration-manager workflow | Nora acts as integrator — reviews Sam's screen PRs, Priya's illustration PRs, and Kai's pipeline PRs before merging to `main` | -| Design system release cycle | Team releases SketchSpark `v0.5-alpha`: the sketch-to-options pipeline works end to end. Tag, archive, changelog. Sam creates `design-tokens.json` for handoff to Kai's frontend. | -| Email workflow → skip notice | "The SketchSpark team uses GitHub PRs for all collaboration. Email-based patches are a legacy workflow — skip unless contributing to projects that require them." | - -### Chapter 6 — Public Beta & Community - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Replace Arduino blink with design system PR | Marcus forks SketchSpark, creates `feature/mobile-prompt-template`, improves `prompts/sketch-to-ui.txt` for better mobile layout generation, opens PR with before/after screenshots of generated options | -| Expand image embedding for reviews | Marcus includes side-by-side screenshots: "Current mobile output" vs. "Improved mobile output" with 5 generated options each. Nora annotates with feedback directly in the PR. | -| CONTRIBUTING.md for design projects | Nora writes guidelines: prompt template format, illustration specs (2x resolution, brand palette), screen mockup naming conventions, accessibility requirements for generated UI | -| GitHub Pages for documentation | Team deploys SketchSpark user docs and API reference to `sketchspark.github.io` | -| Async collaboration norms | Marcus is in a different timezone — PR review takes 24 hours. Nora leaves detailed written feedback with annotated screenshots rather than expecting a synchronous call. | - -### Chapter 7 — Production Hardening - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Stashing scenario | Sam is redesigning the results comparison screen; urgent bug report — the onboarding flow crashes on tablet. Sam stashes his half-finished screens, switches to `fix/onboarding-tablet`, fixes the layout, merges, pops his stash, and continues. | -| `git blame` for design files | Priya uses `git blame illustrations/onboarding/step-2.png` to find who changed the illustration's color palette — it drifted from the brand guide three commits ago during a rushed sprint. | -| Interactive staging | Nora's `product-brief.md` has both a scope change (adding tablet support) and a research update (new user interview findings). She stages only the research update for the current PR, saving the scope change for a separate review. | -| Reset demystified | Sam accidentally commits directly to `main` instead of his feature branch — uses `git reset --soft HEAD~1` to move the commit back to staging, then creates the correct branch. | -| Squashing messy history | Sam squashes "Update results layout" + "Fix results layout spacing" + "Actually fix the spacing this time" + "Tweak padding" into clean "Redesign results comparison screen for card layout" | -| Submodules | Kai's AI pipeline repo (`sketchspark-ml`) becomes a submodule of the main product repo. When the model improves option generation quality, Kai updates the submodule pointer and the team pulls the new version. | - -### Chapter 8 — Process & Automation - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| `.gitattributes` for binary files | Nora configures: `*.png binary`, `*.fig binary`, `*.svg diff`, `*.md diff`, `*.yaml diff` — so Git knows which files can be meaningfully diffed | -| Commit message template | Team template enforced by hook: `[Phase: Component] Description` — e.g., `[Design: Results Screen] Add tablet breakpoint layout` or `[Research: Persona] Update early-adopter goals after round 2 interviews` | -| Pre-commit hook | Hook validates that `model-params.yaml` is valid YAML, checks that prompt templates in `prompts/` don't exceed 4096 tokens, and warns if PNG files exceed 5MB | -| Image diffing | Nora sets up EXIF-based diffing so `git diff` shows metadata changes on exported screen mockups — dimensions, color profile, export date | -| Export-ignore | `.fig` source files and `research/raw-interviews/` are versioned in Git but excluded from release archives via `.gitattributes export-ignore` | - -### Chapter 9 — Legacy Migration - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| SVN design archive migration | SketchSpark acquires a competitor ("QuickMock") whose 3 years of mockups, user research, and design assets live in SVN. Nora leads the migration into the SketchSpark repo. | -| Large binary file handling | Migration surfaces 400MB of PSD source files and high-res mockups — team configures Git LFS for files >10MB | -| Pre-import planning | Nora audits total size, identifies files for LFS, maps QuickMock's flat folder structure to SketchSpark's organized directory hierarchy, and plans which history to preserve vs. squash | - -### Chapter 10 — Scale & Recovery - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Reflog for data recovery | Two days before the v1.0 launch, Sam runs `git reset --hard` on `main` by accident, losing three days of final polish commits. Nora uses `git reflog` to find the lost HEAD, creates a recovery branch, and restores everything. | -| Objects as "fingerprints" | Nora explains to Sam: "Every version of every file — every screen mockup, every prompt template, every research note — gets a unique ID. Even if you delete a branch, the data is still in Git's object store." | -| Packfiles and performance | Priya notices `git push` takes 90 seconds — learns that Git packs similar illustration files together using delta compression, but her 50MB PSD additions bypass efficient packing. The team moves large files to LFS. | -| References as labels | "Branches are just labels pointing to commits — like sticky notes on a timeline. Moving them doesn't destroy anything. That's why Sam's 'lost' work was still there." | - -### Appendix A — Tooling Choices - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Decision tree | Nora uses CLI (fastest for research doc workflows), Sam prefers VS Code's Git panel (inline diffs of screen designs and tokens), Priya uses GitHub Desktop (visual staging of large illustration files), Kai uses JetBrains (integrated with Python ML pipeline) | -| VS Code for token workflows | Sam edits `design-tokens.json` and `user-flows.md` with inline Git gutter indicators showing what changed since last commit | - -### Appendix B — Tool Integration - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Design tool internals | Kai explains how SketchSpark's own generation pipeline uses libgit2 to version-control each of the 5 generated options as lightweight branches — the product's architecture mirrors Git's branching model | -| UX patterns for Git integration | Nora designs SketchSpark's "version history" panel — translating Git concepts (commits, branches, diffs) into a visual interface that non-technical designers can use | -| Dulwich / Python integration | Priya's export script uses Dulwich to auto-commit illustration assets to Git whenever she exports from her design tool — removing manual `git add` from her workflow | - -### Appendix C — Reference - -| Revision Note Recommendation | Storyline Scene | -|------------------------------|-----------------| -| Workflow-based organization | Commands grouped by SketchSpark workflow: "Starting a research phase" (init, clone, branch), "Daily design work" (status, add, commit, diff), "Reviewing options" (log, show, diff between branches), "Collaborating" (push, pull, fetch, merge), "Shipping a release" (tag, archive, merge to main) | - ---- - -## Key Benefits of the Unified Storyline - -1. **Progressive complexity**: readers learn Git operations in the order they'd encounter them building a real product — research notes before merge conflicts, branching before rebasing -2. **Product mirrors Git**: SketchSpark generates 5 parallel options from 1 sketch; Git creates parallel branches from 1 commit. The product's core concept reinforces the most important Git mental model. -3. **Artifact familiarity**: by Chapter 5, `product-brief.md`, `user-flows.md`, and `screens/results/` are familiar landmarks — readers focus on the Git concept, not parsing new file names -4. **Full lifecycle coverage**: research, concept, design, build, test, launch, scale — every phase produces different artifacts (text vs. binary, solo vs. collaborative) that naturally teach different Git workflows -5. **Natural motivation**: each chapter answers "why do I need this?" through the product's progression — branching because the team explores 3 UI options, GitHub because they launched a beta, hooks because they need quality gates before shipping -6. **Character-driven scenarios**: Sam's speed creates stash/reset/recovery lessons; Priya's binary files trigger LFS/attributes lessons; Nora's leadership triggers governance/review/release lessons; Kai's ML pipeline triggers submodule/cross-functional lessons - ---- - -## Risks and Mitigations - -| Risk | Mitigation | -|------|------------| -| Storyline feels forced in reference chapters (App C) | Use storyline as organizational principle, not narrative prose | -| Readers skip chapters and miss context | Each chapter opens with a 2-line "Previously on SketchSpark" recap | -| AI product concept feels niche | The design workflow (research → concept → UI → ship) is universal; the AI generation is flavor, not prerequisite | -| Characters feel contrived | Keep characterization minimal — traits emerge from actions (Sam's messy commits, Priya's large files), not backstory | -| Chapters 9-10 have lower design relevance | Migration and internals are naturally "advanced" — the storyline (acquiring a competitor, recovering before launch) justifies why the team encounters them | -| Binary file challenges recur without resolution | Thread Git LFS as a progressive solution: mentioned Ch1, explained Ch5, configured Ch8, essential in Ch9 | - ---- - -## Implementation Priority - -| Priority | Action | Impact | -|----------|--------|--------| -| 1 | Lock character names, roles, and traits across all chapters | Consistency foundation | -| 2 | Define the `sketchspark/` repo file structure used in examples | Artifact continuity | -| 3 | Rewrite Ch1-3 examples with storyline (highest reader volume, establishes the product) | First impression — readers decide here whether to continue | -| 4 | Rewrite Ch5-6 collaboration examples (most design-relevant, introduces full team) | Core value proposition — collaboration is why designers need Git | -| 5 | Update Ch7-8 tool examples with established artifacts and characters | Builds on familiarity — advanced tools feel less intimidating | -| 6 | Adapt Ch4, Ch9-10, appendices last (infrastructure and advanced topics) | Completeness — important but lower reader volume | diff --git a/00-notes/storyline-rewrite-task.md b/00-notes/storyline-rewrite-task.md deleted file mode 100644 index 9215601dd..000000000 --- a/00-notes/storyline-rewrite-task.md +++ /dev/null @@ -1,29 +0,0 @@ -# Task: Rewrite Storyline Analysis - -## Status: In Progress - -## What Changed -The original `storyline-analysis.md` proposed "Meadow" — a design system for a wellness app — as the unifying storyline across all chapters. **A design system is not a product.** The storyline needs to follow a real product through a real design and development lifecycle. - -## New Direction -Replace the design system storyline with an **AI-powered rapid prototyping product** that: -- Generates up to **5 design options in parallel** from a single sketch -- Covers the **full product lifecycle**: research, concept design, UI design, visual design, development, testing, launch, iteration -- Gives readers a product they can follow from idea through shipping - -## Why This Product -- **Rich design artifact variety**: research docs, personas, journey maps, wireframes, mockups, prototypes, icons, illustrations, motion specs, design tokens, and production assets -- **Parallel generation is inherently visual**: 5 options from 1 sketch naturally produces branching/merging scenarios (each option is a branch; the chosen direction merges to main) -- **AI component adds modern relevance**: model configs, training data references, prompt templates — files that are text-based and Git-friendly alongside binary design files -- **Full lifecycle coverage**: unlike a design system (which is infrastructure), a product has research phases, concept phases, user testing, pivots, launches, and post-launch iteration — each mapping to different Git workflows - -## Requirements for the Rewrite -1. Replace all "Meadow design system" references with the new product concept -2. Redefine the team to reflect product roles (researcher, concept designer, UI/visual designer, engineer) -3. Remap the chapter timeline to product lifecycle phases (research → concept → design → build → test → launch → scale) -4. Update all artifact continuity maps to reflect product files (research briefs, personas, wireframes, screen mockups, prototype configs, AI model params) -5. Update all scene-by-scene mappings to use product scenarios -6. Preserve the structural framework (problem statement, benefits, risks, implementation priority) - -## File to Update -`00-notes/storyline-analysis.md` From e680d19efd765b38339b59b02a74e42ca4a2fdc9 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sun, 12 Apr 2026 18:15:30 +0000 Subject: [PATCH 17/18] Add next-steps document outlining foundational, writing, and strategic tasks Captures the recommended sequence for moving from outlines to drafted chapters: build the sample sketchspark repo, write voice/tone and conventions guides, draft Chapter 1 as a template, then prioritize Chapters 2, 3, 5, 6. Also flags build tooling and illustration planning as strategic decisions that should run in parallel. --- 00-notes/next-steps.md | 131 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 00-notes/next-steps.md diff --git a/00-notes/next-steps.md b/00-notes/next-steps.md new file mode 100644 index 000000000..db40ecad7 --- /dev/null +++ b/00-notes/next-steps.md @@ -0,0 +1,131 @@ +# Next Steps + +Recommended work sequence following the completion of the storyline, product spec, and per-chapter outlines. Tasks are ordered within three phases: foundational (do before prose), writing (execute after foundation), and strategic (resolve in parallel). + +--- + +## Foundational + +These tasks establish the shared infrastructure that every chapter will reference. Completing them first prevents inconsistencies that would otherwise have to be fixed across many chapters later. + +### 1. Build the sample `sketchspark/` repository + +Create an actual directory of placeholder files matching the structure described in `storyline.md`: + +``` +sketchspark/ +├── product-brief.md +├── research/ +├── concept/ +├── screens/ +├── illustrations/ +├── icons/ +├── design-tokens.json +├── pipeline/ +│ ├── model-params.yaml +│ └── prompts/ +├── docs/ +├── CONTRIBUTING.md +├── CHANGELOG.md +├── .gitignore +└── .gitattributes +``` + +Every chapter's walkthroughs run against this repo. Having it exist as real files means commands, diffs, and outputs can be captured verbatim instead of invented. The placeholders do not need to be production-quality — they need to be diffable, committable, and believable. + +### 2. Write a voice and tone guide + +A short document capturing how to write for UX designers learning Git. Covers: + +- Reading level and assumed background (design fluency, no CLI assumption) +- When to use design analogies vs. plain explanation +- How to introduce commands (always show context before syntax) +- Terminology decisions (e.g., "commit" vs. "save," "branch" vs. "version") +- Character voice — how Nora, Sam, Priya, Kai, and Marcus sound in narration +- Illustration style guidance for the diagrams that will eventually replace `images/` + +Target: ~2 pages. Lives at `00-notes/voice-and-tone.md`. + +### 3. Define cross-chapter conventions + +A single source of truth for facts that must remain consistent across every chapter: + +- Branch names used in examples (e.g., `feature/mobile-prompts`, `fix/contrast-audit`) +- Tag names and what milestone each represents (`v0.1-concept`, `v0.5-alpha`, `v0.8-beta`, `v1.0`) +- File paths referenced across chapters +- Commit message format the team uses +- Which character owns which artifact type +- Dates and project timeline anchors + +Lives at `00-notes/conventions.md`. Every chapter outline already references these — this document makes them authoritative. + +--- + +## Writing + +### 4. Write Chapter 1 as a proof of concept + +Chapter 1 is the best candidate for the first prose pass because it sets the voice, establishes Nora as the entry character, and introduces the product. Completing it end-to-end will surface: + +- Whether the outline structure actually translates to readable prose +- How much of the original AsciiDoc can be preserved vs. rewritten +- What the walkthrough format looks like in practice +- How figures and screenshots need to be captured + +Treat the Chapter 1 draft as a template. Decisions made there will propagate to every subsequent chapter. + +### 5. Write Chapters 2, 3, 5, 6 next + +After Chapter 1, prioritize the highest-value chapters: + +- **Chapter 2** (Git Basics) — the daily workflow; most designers will use only this chapter +- **Chapter 3** (Branching) — the feature that most changes a designer's mental model +- **Chapter 5** (Distributed Git) — the team collaboration story; Marcus enters here +- **Chapter 6** (GitHub) — the PR workflow, which is most designers' real interface with Git + +Chapters 4, 7, 8, 9, 10 and the appendices come after these four are stable. Chapter 9 (other SCMs) is the lowest-priority chapter and may not need a full rewrite. + +--- + +## Strategic + +These decisions can be resolved in parallel with foundational and writing work, but they constrain downstream choices and should not be deferred indefinitely. + +### 6. Decide on build tooling and distribution + +Questions to resolve: + +- Does the UX designer edition live as a fork of progit2, a long-lived branch, or a parallel variant with its own master `.asc`? +- Does it build with the existing Asciidoctor pipeline or switch to a different toolchain? +- What output formats ship (HTML, PDF, EPUB, web-only)? +- How will illustrations be integrated (replacing `images/` entirely, or additive)? +- Is the title "Pro Git for UX Designers" or something else? Licensing implications of the CC-BY-NC-SA-3.0 inheritance. + +This decision affects how Chapter 1 gets drafted — prose written for a fork is different from prose written for a standalone book. + +### 7. Plan the illustration replacement + +The existing book has ~150 diagrams in `images/` built from `diagram-source/progit.sketch`. Most need to be redrawn for the new audience because they currently show generic branch diagrams, not design workflows. + +Plan: + +- Inventory the existing 150 diagrams and tag each as "keep," "adapt," or "replace" +- Identify new illustrations the storyline requires (SketchSpark screens, team avatars, repository structure, PR review interface) +- Decide illustration style (hand-drawn, flat vector, screenshot-with-callouts) +- Choose the source tool — Figma (matches the book's subject), Sketch (matches the original), or something else +- Budget: illustration work is typically the longest-lead item in a technical book revision + +Lives at `00-notes/illustration-plan.md` once started. + +--- + +## Suggested Order + +1. Cross-chapter conventions (fastest — pulls from outlines that already exist) +2. Sample `sketchspark/` repo skeleton (unblocks every walkthrough) +3. Voice and tone guide (unblocks prose) +4. Build tooling decision (unblocks Chapter 1 drafting) +5. Chapter 1 draft +6. Illustration inventory (can run in parallel with Chapter 1) +7. Chapters 2, 3, 5, 6 +8. Remaining chapters and appendices From d8d25a01e9258cc52d2ea6cfae0a8f071562473d Mon Sep 17 00:00:00 2001 From: William Trekell <wtrekell@gmail.com> Date: Sat, 16 May 2026 06:42:18 -0700 Subject: [PATCH 18/18] chore: pre-build sync --- .gemini/skills/sketchspark-author/SKILL.md | 31 + .../references/conventions.md | 56 ++ .../sketchspark-author/references/lexicon.md | 28 + .../sketchspark-author/references/spec.md | 298 +++++++ .../references/storyline.md | 682 +++++++++++++++ .../sketchspark-author/references/voice.md | 30 + 00-notes/conventions.md | 56 ++ 00-notes/voice-and-tone.md | 30 + B-embedding-git-in-your-applications.asc | 6 +- C-git-commands.asc | 598 +------------ GEMINI.md | 71 ++ .../sections/about-version-control.asc | 68 +- .../01-introduction/sections/command-line.asc | 16 +- .../sections/first-time-setup.asc | 116 +-- book/01-introduction/sections/help.asc | 31 +- book/01-introduction/sections/history.asc | 25 +- book/01-introduction/sections/installing.asc | 117 +-- book/01-introduction/sections/what-is-git.asc | 108 +-- book/02-git-basics/sections/aliases.asc | 73 +- .../sections/getting-a-repository.asc | 82 +- .../sections/recording-changes.asc | 625 +++----------- book/02-git-basics/sections/remotes.asc | 228 +---- book/02-git-basics/sections/tagging.asc | 287 ++----- book/02-git-basics/sections/undoing.asc | 228 +---- .../sections/viewing-history.asc | 314 ++----- .../sections/basic-branching-and-merging.asc | 321 ++----- .../sections/branch-management.asc | 196 ++--- book/03-git-branching/sections/nutshell.asc | 190 +--- book/03-git-branching/sections/rebasing.asc | 240 +----- .../sections/remote-branches.asc | 235 +---- book/03-git-branching/sections/workflows.asc | 66 +- .../sections/generating-ssh-key.asc | 66 +- .../sections/git-on-a-server.asc | 100 +-- book/04-git-server/sections/hosted.asc | 15 +- book/04-git-server/sections/protocols.asc | 207 +---- .../sections/contributing.asc | 809 +----------------- .../sections/distributed-workflows.asc | 97 +-- .../sections/maintaining.asc | 562 +----------- .../sections/1-setting-up-account.asc | 97 +-- book/06-github/sections/2-contributing.asc | 557 +----------- book/06-github/sections/3-maintaining.asc | 385 +-------- .../sections/4-managing-organization.asc | 75 +- book/06-github/sections/5-scripting.asc | 304 +------ .../sections/interactive-staging.asc | 216 +---- book/07-git-tools/sections/reset.asc | 345 +------- .../sections/revision-selection.asc | 391 +-------- .../sections/rewriting-history.asc | 410 +-------- book/07-git-tools/sections/searching.asc | 159 +--- .../sections/stashing-cleaning.asc | 293 +------ .../sections/attributes.asc | 373 +------- book/08-customizing-git/sections/config.asc | 512 +---------- book/08-customizing-git/sections/hooks.asc | 152 +--- book/08-customizing-git/sections/policy.asc | 450 +--------- .../sections/client-svn.asc | 492 +---------- .../sections/import-custom.asc | 378 +------- .../sections/import-svn.asc | 154 +--- .../10-git-internals/sections/maintenance.asc | 356 +------- book/10-git-internals/sections/objects.asc | 441 +--------- .../sections/plumbing-porcelain.asc | 49 +- book/10-git-internals/sections/refs.asc | 214 +---- .../sections/bash.asc | 47 +- .../sections/guis.asc | 159 +--- .../sections/jetbrainsides.asc | 20 +- .../sections/visualstudiocode.asc | 31 +- .../sections/zsh.asc | 59 +- .../B-embedding-git/sections/command-line.asc | 23 +- .../B-embedding-git/sections/introduction.asc | 10 + book/B-embedding-git/sections/libgit2.asc | 228 +---- book/GEMINI.md | 30 + ch01-getting-started.asc | 9 +- ch02-git-basics-chapter.asc | 21 +- ch03-git-branching.asc | 22 +- ch04-git-on-the-server.asc | 36 +- ch05-distributed-git.asc | 12 +- ch06-github.asc | 23 +- ch07-git-tools.asc | 31 +- ch08-customizing-git.asc | 15 +- ch09-git-and-other-systems.asc | 37 +- ch10-git-internals.asc | 36 +- sketchspark-author.skill | Bin 0 -> 26332 bytes sketchspark-author/SKILL.md | 31 + sketchspark-author/references/conventions.md | 56 ++ sketchspark-author/references/lexicon.md | 28 + sketchspark-author/references/spec.md | 298 +++++++ sketchspark-author/references/storyline.md | 682 +++++++++++++++ sketchspark-author/references/voice.md | 30 + sketchspark/.gitattributes | 0 sketchspark/.gitignore | 5 + sketchspark/CHANGELOG.md | 0 sketchspark/CONTRIBUTING.md | 0 .../concept/information-architecture.md | 0 sketchspark/concept/user-flows.md | 0 sketchspark/design-tokens.json | 14 + sketchspark/pipeline/model-params.yaml | 0 sketchspark/product-brief.md | 15 + sketchspark/research/competitive-analysis.md | 0 96 files changed, 4362 insertions(+), 11757 deletions(-) create mode 100644 .gemini/skills/sketchspark-author/SKILL.md create mode 100644 .gemini/skills/sketchspark-author/references/conventions.md create mode 100644 .gemini/skills/sketchspark-author/references/lexicon.md create mode 100644 .gemini/skills/sketchspark-author/references/spec.md create mode 100644 .gemini/skills/sketchspark-author/references/storyline.md create mode 100644 .gemini/skills/sketchspark-author/references/voice.md create mode 100644 00-notes/conventions.md create mode 100644 00-notes/voice-and-tone.md create mode 100644 GEMINI.md create mode 100644 book/B-embedding-git/sections/introduction.asc create mode 100644 book/GEMINI.md create mode 100644 sketchspark-author.skill create mode 100644 sketchspark-author/SKILL.md create mode 100644 sketchspark-author/references/conventions.md create mode 100644 sketchspark-author/references/lexicon.md create mode 100644 sketchspark-author/references/spec.md create mode 100644 sketchspark-author/references/storyline.md create mode 100644 sketchspark-author/references/voice.md create mode 100644 sketchspark/.gitattributes create mode 100644 sketchspark/.gitignore create mode 100644 sketchspark/CHANGELOG.md create mode 100644 sketchspark/CONTRIBUTING.md create mode 100644 sketchspark/concept/information-architecture.md create mode 100644 sketchspark/concept/user-flows.md create mode 100644 sketchspark/design-tokens.json create mode 100644 sketchspark/pipeline/model-params.yaml create mode 100644 sketchspark/product-brief.md create mode 100644 sketchspark/research/competitive-analysis.md diff --git a/.gemini/skills/sketchspark-author/SKILL.md b/.gemini/skills/sketchspark-author/SKILL.md new file mode 100644 index 000000000..566060e4c --- /dev/null +++ b/.gemini/skills/sketchspark-author/SKILL.md @@ -0,0 +1,31 @@ +--- +name: sketchspark-author +description: Specialized authoring guide for the "Pro Git for UX Designers" book revision. Use when writing, editing, or outlining chapters for the SketchSpark storyline. +--- + +# SketchSpark Authoring Skill + +Use this skill to author high-quality, consistent content for the "Pro Git for UX Designers" revision. + +## Authoring Workflow + +1. **Context Alignment:** Identify the target chapter and its storyline goals in [storyline.md](references/storyline.md). +2. **Voice Check:** Ensure your writing style matches the [Voice and Tone Guide](references/voice.md). +3. **Convention Verification:** Use character names, branch names, and milestones from [conventions.md](references/conventions.md). +4. **Content Tagging:** Apply the correct tag to each section based on the [Content Type Lexicon](references/lexicon.md). +5. **Technical Validation:** Reference the [SketchSpark Product Spec](references/spec.md) for technical accuracy of the AI prototyping workflow. + +## Guidelines + +- **Empathetic Narration:** Focus on Nora and Sam's journey. Relate Git commands to design pain points (e.g., losing research, managing multiple layout explorations). +- **AsciiDoc Formatting:** Use standard AsciiDoc for sections (`==`, `===`, `====`), source blocks (`[source,bash]`), and tags (`tag::type[]`). +- **Simulated Commands:** When providing terminal examples, use the `sketchspark/` directory structure. +- **Commit Messages:** Always use the `[Phase: Component]` prefix convention. + +## Detailed References + +- **[storyline.md](references/storyline.md)**: The 10-chapter narrative arc. +- **[spec.md](references/spec.md)**: Product details for SketchSpark. +- **[lexicon.md](references/lexicon.md)**: Tag definitions for sections. +- **[conventions.md](references/conventions.md)**: Naming standards. +- **[voice.md](references/voice.md)**: Persona and style guidance. diff --git a/.gemini/skills/sketchspark-author/references/conventions.md b/.gemini/skills/sketchspark-author/references/conventions.md new file mode 100644 index 000000000..e933ca071 --- /dev/null +++ b/.gemini/skills/sketchspark-author/references/conventions.md @@ -0,0 +1,56 @@ +# Cross-Chapter Conventions + +This document ensures consistency across the entire book. All walkthroughs and prose must adhere to these facts. + +## The SketchSpark Team +- **Nora:** UX Lead (CLI user) +- **Sam:** UI Designer (VS Code user) +- **Priya:** Illustrator (GitHub Desktop user) +- **Kai:** Frontend/ML Engineer (JetBrains user) +- **Marcus:** Community Contributor (fork-and-PR workflow) + +## Repository Structure +The repo name is always `sketchspark`. +``` +sketchspark/ +├── product-brief.md +├── research/ +├── concept/ +├── screens/ +├── illustrations/ +├── icons/ +├── design-tokens.json +├── pipeline/ +├── docs/ +├── CONTRIBUTING.md +├── CHANGELOG.md +├── .gitignore +└── .gitattributes +``` + +## Milestone Tags +- `v0.1-concept`: Concept approved, wireframes in place. +- `v0.5-alpha`: End-to-end pipeline working (web). +- `v0.8-beta`: Multi-platform, design token integration. +- `v1.0`: Public launch, refinement editor. + +## Standard Branch Names +- `main`: The stable version of the truth. +- `option/<name>`: Design explorations (e.g., `option/card-layout`). +- `feature/<name>`: Approved work (e.g., `feature/onboarding-illustrations`). +- `fix/<name>`: Corrections (e.g., `fix/contrast-audit`). +- `research/<name>`: Discovery work. + +## Commit Message Format +The team uses a `[Phase: Component]` prefix: +- `[Design: Results Screen] Add overlay diff comparison mode` +- `[Research: Persona] Update early-adopter goals` +- `[Pipeline: Prompts] Improve mobile layout generation` +- `[Fix: Onboarding] Correct tablet breakpoint` + +## Key File Ownership +- `product-brief.md`, `research/`: Owned by Nora. +- `screens/`, `design-tokens.json`: Owned by Sam. +- `illustrations/`, `icons/`: Owned by Priya. +- `pipeline/`: Owned by Kai. +- `prompts/`: Edited by Kai and Marcus. diff --git a/.gemini/skills/sketchspark-author/references/lexicon.md b/.gemini/skills/sketchspark-author/references/lexicon.md new file mode 100644 index 000000000..046c4b203 --- /dev/null +++ b/.gemini/skills/sketchspark-author/references/lexicon.md @@ -0,0 +1,28 @@ +# Content Type Lexicon + +This lexicon defines the content type tags used across all chapter TOC files. +Each sub-section is tagged to describe the **primary kind of content** it delivers. + +## Content Types + +| Tag | Meaning | +|--------------|---------------------------------------------------------------------------------------------| +| `concept` | Explains an idea, model, or theory. Answers "what is this?" or "how does this work?" | +| `walkthrough`| Step-by-step narrative that guides the reader through a realistic scenario or workflow | +| `procedure` | Task-oriented instructions: do X, then Y, then Z. Answers "how do I do this?" | +| `reference` | Lookup-oriented listing of options, flags, commands, or settings | +| `history` | Historical narrative or background context about origins and evolution | +| `comparison` | Evaluates alternatives side-by-side, including pros/cons and trade-offs | +| `diagram` | Primarily visual — uses diagrams or figures to explain a model or data structure | +| `recipe` | Short, self-contained example showing a specific technique or tip | +| `config` | Configuration-focused: editing config files, setting options, customizing behavior | +| `internals` | Deep dive into underlying mechanisms, data structures, or protocols | +| `overview` | Brief orientation or survey — introduces a topic area without going deep | +| `integration`| Covers connecting Git with external tools, services, or platforms | + +## Usage Rules + +1. Every sub-section (`====` level) and leaf section (`===` with no children) gets exactly one tag. +2. Parent sections (`===` with children) do **not** get tagged — the children carry the type. +3. When a section blends types, choose the **dominant** one (>50% of content). +4. `Summary` sections at chapter end are tagged `overview` (they recap, not introduce). diff --git a/.gemini/skills/sketchspark-author/references/spec.md b/.gemini/skills/sketchspark-author/references/spec.md new file mode 100644 index 000000000..075d9a515 --- /dev/null +++ b/.gemini/skills/sketchspark-author/references/spec.md @@ -0,0 +1,298 @@ +# SketchSpark — Product Specification + +## What Is SketchSpark? + +SketchSpark is an AI-powered rapid prototyping application that turns rough sketches into polished UI designs. A designer provides a single input — a napkin wireframe, a whiteboard photo, a tablet drawing, or a simple digital sketch — and SketchSpark generates up to five distinct, high-fidelity UI options in parallel. The designer reviews, compares, selects a direction, and refines it iteratively until the design is ready for development handoff. + +--- + +## The Problem + +The gap between idea and testable prototype is the slowest part of the design process. A designer has a concept — maybe sketched on paper during a meeting, maybe roughed out on a tablet on the train home — and turning that into something a team can evaluate takes hours or days. Wireframing tools require manual construction of every element. High-fidelity mockup tools demand pixel-level precision before anything looks real enough to test. + +Meanwhile, the best design decisions come from comparing options. Research consistently shows that teams who evaluate multiple directions produce stronger outcomes than teams who refine a single idea. But generating multiple polished directions multiplies the time cost — so in practice, most teams explore one direction and hope it's the right one. + +SketchSpark eliminates this tradeoff. + +--- + +## Core Interaction Model + +### Input +The designer provides a rough sketch through one of three input methods: + +1. **Upload**: Photograph of a hand-drawn sketch (napkin, whiteboard, notebook), uploaded as JPEG or PNG +2. **Draw**: Freehand sketch drawn directly in the SketchSpark canvas using a mouse, trackpad, or stylus +3. **Import**: Existing low-fidelity wireframe imported from Figma, Sketch, or as SVG/PNG + +The sketch does not need to be precise. SketchSpark interprets intent: a rectangle becomes a card, a circle becomes an avatar, a squiggle with lines becomes a text block, an arrow becomes navigation. The AI model is trained to read rough spatial relationships and structural patterns, not pixel-perfect drawings. + +### Processing +SketchSpark analyzes the sketch and generates up to five UI interpretations simultaneously. Each option: + +- Applies a different layout strategy (grid, list, asymmetric, card-based, editorial) +- Respects the spatial relationships in the original sketch +- Uses the project's design tokens (colors, typography, spacing) if configured +- Follows platform conventions (iOS, Android, or web) based on project settings +- Meets WCAG AA accessibility standards by default (contrast, touch targets, font sizes) + +Generation takes 15–45 seconds depending on sketch complexity and selected platform. + +### Output +The results screen presents all generated options in a side-by-side comparison view. For each option, the designer sees: + +- A full-fidelity screen mockup at the target resolution +- A confidence score (how closely the option matches the sketch's intent) +- Layout strategy label (e.g., "Card Grid," "Editorial Stack," "Split Panel") +- Quick annotations highlighting key interpretation decisions + +The designer can: + +- **Select** an option to use as the starting point for refinement +- **Compare** two options in an overlay diff view (superimposed at 50% opacity) +- **Regenerate** a single option with adjusted parameters (e.g., "more whitespace," "larger typography") +- **Refine** the selected option in an integrated editor with AI-assisted adjustments +- **Export** any option as Figma file, SVG, PNG, or development-ready code (HTML/CSS or React components) + +### Iteration +After selecting a direction, the designer enters the refinement loop: + +1. Adjust the selected design (move elements, change hierarchy, update content) +2. Ask SketchSpark to regenerate variations of the adjusted design +3. Compare, select, adjust again +4. Repeat until satisfied + +Each iteration takes seconds, not hours. The designer maintains creative control — SketchSpark generates options, the designer makes decisions. + +--- + +## Product Architecture + +### Core Screens + +| Screen | Purpose | Key Interactions | +|--------|---------|------------------| +| **Home / Dashboard** | Project list, recent sketches, quick-start | Create new project, open recent, view history | +| **Sketch Input** | Upload, draw, or import the source sketch | Drag-and-drop upload, freehand canvas, file picker, Figma import | +| **Generation Progress** | Loading state during AI processing | Progress indicator, cancel button, "What's happening" explainer | +| **Results Comparison** | Side-by-side view of 5 generated options | Select, compare overlay, regenerate single, expand detail | +| **Refinement Editor** | Edit selected option with AI assistance | Direct manipulation, AI regeneration of subsections, token application | +| **Export** | Output to design tools or development formats | Figma, Sketch, SVG, PNG, HTML/CSS, React components | +| **History** | Version timeline of all generations and refinements | Browse, restore, branch from any point | +| **Settings** | Project configuration | Platform target, design tokens, team preferences, API keys | +| **Onboarding** | First-run experience for new users | 3-step tutorial: upload → generate → refine | + +### Platform Targets +SketchSpark generates designs for three platforms: + +- **Web** (responsive: desktop 1440px, tablet 768px, mobile 375px) +- **iOS** (iPhone 15 Pro, iPad Pro) +- **Android** (Pixel 8, Galaxy Tab) + +Platform selection affects layout conventions, navigation patterns, typography scales, and touch target sizes. A single sketch can generate options for multiple platforms simultaneously. + +### Design Token Integration +Projects can define design tokens (via `design-tokens.json`) that constrain generation: + +```json +{ + "colors": { + "primary": "#2563EB", + "secondary": "#7C3AED", + "surface": "#FFFFFF", + "on-surface": "#1E293B", + "error": "#DC2626", + "success": "#16A34A" + }, + "typography": { + "heading-1": { "family": "Inter", "weight": 700, "size": "32px", "line-height": 1.2 }, + "heading-2": { "family": "Inter", "weight": 600, "size": "24px", "line-height": 1.3 }, + "body": { "family": "Inter", "weight": 400, "size": "16px", "line-height": 1.5 }, + "caption": { "family": "Inter", "weight": 400, "size": "12px", "line-height": 1.4 } + }, + "spacing": { + "xs": "4px", + "sm": "8px", + "md": "16px", + "lg": "24px", + "xl": "32px", + "2xl": "48px" + }, + "border-radius": { + "sm": "4px", + "md": "8px", + "lg": "16px", + "full": "9999px" + } +} +``` + +When tokens are configured, all generated options use them — ensuring brand consistency across every variation. When tokens are absent, SketchSpark applies sensible defaults. + +--- + +## AI Generation Pipeline + +### Sketch Interpretation +The input sketch passes through a vision model that identifies: + +- **Elements**: rectangles (cards, containers), circles (avatars, icons), lines (dividers, borders), text blocks, arrows (navigation, flow), images (placeholders) +- **Hierarchy**: relative size indicates importance; vertical position indicates reading order +- **Grouping**: proximity and alignment suggest related elements +- **Intent patterns**: recognized UI conventions (tab bar, header, list, form, modal) + +### Option Generation +Each of the five options is generated by the same base model with different layout strategy parameters: + +| Option | Strategy | Characteristics | +|--------|----------|-----------------| +| Option 1 | **Faithful** | Closest interpretation of the sketch's literal layout | +| Option 2 | **Grid** | Elements reorganized into a structured grid system | +| Option 3 | **Editorial** | Asymmetric, magazine-style layout with visual hierarchy emphasis | +| Option 4 | **Minimal** | Maximum whitespace, reduced elements, focus on core content | +| Option 5 | **Dense** | Information-rich, compact layout maximizing content density | + +The strategies are configurable. Teams can replace defaults or add custom strategies via prompt templates (`prompts/sketch-to-ui.txt`, `prompts/mobile-layout.txt`). + +### Prompt Templates +The generation pipeline uses text-based prompt templates that define how the model interprets and renders sketches: + +``` +# prompts/sketch-to-ui.txt +# Core generation prompt for SketchSpark + +## System Context +You are a UI design generator. Given a sketch analysis (element positions, +hierarchy, grouping, intent patterns), generate a high-fidelity UI mockup. + +## Constraints +- Apply design tokens if provided; use system defaults otherwise +- Meet WCAG AA contrast ratios (4.5:1 for body text, 3:1 for large text) +- Touch targets minimum 44x44px for mobile, 24x24px for web +- Respect platform conventions for navigation, typography, and spacing + +## Layout Strategy: {strategy_name} +{strategy_description} + +## Output +Render as structured layout definition with element positions, styles, +and content. Include accessibility labels for all interactive elements. +``` + +These templates are plain text files — fully version-controllable, diffable, and improvable via pull requests (as Marcus demonstrates in Chapter 6). + +### Accessibility +Every generated option includes: + +- WCAG AA contrast compliance (checked automatically, violations flagged) +- Semantic structure (headings, landmarks, reading order) +- Touch target sizing per platform guidelines +- Alt text suggestions for image placeholders +- Focus order and keyboard navigation hints + +An optional post-generation accessibility audit (`prompts/accessibility-check.txt`) runs a second pass and annotates the design with specific compliance notes. + +### Model Configuration +The AI model's behavior is controlled through `model-params.yaml`: + +```yaml +model: + version: "sketchspark-v3.2" + inference: + temperature: 0.7 # Higher = more creative variation between options + max_tokens: 8192 + timeout_seconds: 45 + generation: + num_options: 5 # 1-5 parallel options + min_confidence: 0.6 # Don't show options below this confidence + platform: "web" # web | ios | android + responsive_breakpoints: + - 1440 + - 768 + - 375 + quality: + accessibility_level: "AA" # AA | AAA + contrast_check: true + touch_target_check: true +``` + +This file is structured YAML — Git can diff it, hooks can validate it, and changes are traceable through commit history. + +--- + +## User Roles and Workflows + +### Solo Designer (Freelancer) +- Uploads client sketches, generates options, presents 3–5 directions to the client +- Uses SketchSpark to compress the "sketch to mockup" phase from 2 days to 2 hours +- Exports directly to Figma for final polish and handoff + +### Design Team (3–8 people) +- Shared project with design tokens enforcing brand consistency +- Multiple designers generate options for different screens simultaneously +- Results comparison view used in team critiques — "let's look at everyone's options for the checkout flow" +- History view tracks who generated what and which directions were chosen + +### Design-Engineering Handoff +- Selected designs export as development-ready code (HTML/CSS or React components) +- Design tokens ensure generated code uses the same spacing, colors, and typography as the design +- Engineers consume tokens from `design-tokens.json` in their build system +- Version history provides context: "why does this screen look this way?" → trace back to the original sketch and the option selection decision + +--- + +## Technical Stack (for repository context) + +| Layer | Technology | Repository Artifacts | +|-------|-----------|---------------------| +| Frontend | React + TypeScript | `src/` (not in design repo) | +| Design | Figma (source), PNG/SVG (exports) | `screens/`, `illustrations/`, `icons/` | +| AI Pipeline | Python + PyTorch | `pipeline/`, `model-params.yaml`, `prompts/` | +| Design Tokens | JSON (consumed by both design and engineering) | `design-tokens.json` | +| Documentation | Markdown | `docs/`, `product-brief.md`, `research/` | +| CI/CD | GitHub Actions | `.github/workflows/` | + +The design repository (the one tracked in the book's storyline) contains everything except the frontend source code. This is intentional — the repo is a designer's workspace, not an engineering monorepo. + +--- + +## Product Milestones (as referenced in the storyline) + +| Tag | Milestone | What's Working | +|-----|-----------|----------------| +| `v0.1-concept` | Concept approved | Product brief, personas, competitive analysis, initial user flows, wireframes | +| `v0.5-alpha` | Internal alpha | End-to-end pipeline: upload sketch → generate 5 options → view comparison. Single platform (web). Default tokens only. | +| `v0.8-beta` | Public beta | All three input methods. Web + iOS platforms. Design token integration. Export to Figma and PNG. Onboarding flow. GitHub public repo. | +| `v1.0` | Public launch | All platforms. Refinement editor. Code export. Accessibility audit. Team collaboration features. Mobile prompt improvements (Marcus's contribution). QuickMock migration complete. | + +--- + +## Competitive Landscape + +| Competitor | What It Does | How SketchSpark Differs | +|-----------|-------------|------------------------| +| **Figma** | Collaborative design tool | Figma is the canvas; SketchSpark is the idea accelerator. Exports *to* Figma. | +| **Uizard** | AI screen generation from text prompts | Text-to-UI vs. sketch-to-UI. SketchSpark preserves the designer's spatial intent. | +| **Galileo AI** | AI UI generation from text descriptions | Similar AI approach but text-driven. SketchSpark starts from visual input. | +| **Framer** | Design + publish tool with AI features | Framer focuses on shipping websites. SketchSpark focuses on the exploration phase. | +| **Midjourney / DALL-E** | General image generation | Produces images, not structured UI. Can't export to Figma or generate code. No accessibility checking. | + +SketchSpark's differentiator: **parallel options from spatial input**. The designer's sketch encodes intent that text prompts can't — relative sizing, spatial grouping, reading order. Five options from one sketch means the designer explores more of the solution space in less time than any competitor allows. + +--- + +## Why This Product Works as a Book Example + +SketchSpark is designed to serve double duty as a compelling product *and* an effective Git teaching vehicle: + +1. **Parallel generation mirrors branching.** Five options from one sketch is the same mental model as five branches from one commit. The product's core concept reinforces Git's most important feature. + +2. **Full design lifecycle.** Research → concept → exploration → build → beta → launch → scale. Every phase produces different artifact types (text, binary, structured config) that teach different Git workflows. + +3. **Mixed file types.** Research briefs (merge-friendly markdown), screen mockups (binary Figma exports), AI prompts (diffable text), illustrations (large binary PNGs), tokens (structured JSON). This variety naturally teaches Git's strengths and limitations. + +4. **Team growth.** Solo (Ch1–2) → pair (Ch3) → small team (Ch5) → open source (Ch6). Each growth stage demands the exact Git workflow that chapter teaches. + +5. **AI pipeline.** Model configs, prompt templates, and training manifests are text files that benefit from version control, validation hooks, and code review — making chapters on hooks, attributes, and collaboration feel immediately relevant rather than abstract. + +6. **Real product decisions.** "Should we use card layout or list layout?" is a design decision readers can visualize. It's more engaging than "should we use tabs or spaces?" — and it naturally becomes a branch, a PR, and a merge. diff --git a/.gemini/skills/sketchspark-author/references/storyline.md b/.gemini/skills/sketchspark-author/references/storyline.md new file mode 100644 index 000000000..23215cf51 --- /dev/null +++ b/.gemini/skills/sketchspark-author/references/storyline.md @@ -0,0 +1,682 @@ +# The SketchSpark Storyline + +## The Product + +**SketchSpark** is an AI-powered rapid prototyping application. A designer uploads or draws a rough sketch — a napkin wireframe, a whiteboard photo, a tablet drawing — and SketchSpark generates up to five polished UI options in parallel. The designer reviews, compares, selects a direction, refines it, and iterates toward a shippable product. + +The product serves a gap in the design-to-development pipeline: the jump from rough idea to testable prototype is slow. SketchSpark collapses it from days to minutes. + +--- + +## The Team + +**Nora** — UX Lead and Product Owner. She came from agency work where she managed design research across dozens of client projects, all versioned as "final_v3_REAL_USE-THIS.pdf" on shared drives. She's methodical, writes thorough briefs, and sets process standards. She's the one who brings Git to the team after a catastrophic file loss. She uses the CLI. + +**Sam** — UI and Visual Designer. He's fast. He generates screen layouts the way a jazz musician improvises — quickly, instinctively, and sometimes messily. He commits too often with vague messages, works on the wrong branch, and forgets to pull before pushing. Every Git mistake a designer can make, Sam makes first. He uses VS Code. + +**Priya** — Concept Designer and Illustrator. She creates the product's visual identity: onboarding illustrations, marketing assets, icon sets, and high-fidelity mockups. Her files are large — 30MB PSDs, layered Sketch files, high-resolution PNGs. She's the team member who stress-tests Git's handling of binary files. She uses GitHub Desktop. + +**Kai** — Frontend Engineer and ML Integration Lead. He joins when the product moves from concept to build. He maintains the AI generation pipeline: model parameters, prompt templates, training data manifests. His files are structured text (YAML, JSON, plain text) that merge cleanly — the opposite of Priya's binaries. He bridges design and engineering. He uses JetBrains. + +**Marcus** — External Contributor. He appears in Chapter 6 when SketchSpark goes public beta. He's a designer in another timezone who forks the repo, improves a prompt template for mobile layouts, and submits a pull request. He represents the open-source contribution experience. + +--- + +## The Repository + +``` +sketchspark/ +├── product-brief.md # The source of truth — what are we building and why +├── research/ +│ ├── personas/ +│ │ ├── early-adopter.md # Primary persona: freelance UI designer +│ │ └── team-lead.md # Secondary persona: design team manager +│ ├── competitive-analysis.md # Landscape of existing prototyping tools +│ ├── interview-notes/ +│ │ ├── round-1-findings.md # Initial discovery interviews +│ │ └── round-2-findings.md # Post-alpha validation interviews +│ └── journey-maps/ +│ └── sketch-to-prototype.png # Current-state journey map (binary) +├── concept/ +│ ├── information-architecture.md # App structure and navigation model +│ ├── user-flows.md # Step-by-step task flows +│ └── wireframes/ +│ ├── sketch-input.png # Upload/draw screen (binary) +│ └── results-comparison.png # Side-by-side options screen (binary) +├── screens/ +│ ├── onboarding/ +│ │ ├── welcome.fig # Figma source (binary, large) +│ │ └── welcome.png # Exported preview +│ ├── sketch-input/ +│ │ ├── upload-flow.fig +│ │ └── upload-flow.png +│ └── results/ +│ ├── card-layout.fig +│ ├── card-layout.png +│ ├── list-layout.fig +│ ├── list-layout.png +│ ├── canvas-freeform.fig +│ └── canvas-freeform.png +├── illustrations/ +│ ├── onboarding/ +│ │ ├── step-1-upload.png # Large illustrated graphics (binary) +│ │ ├── step-2-generate.png +│ │ └── step-3-refine.png +│ └── marketing/ +│ └── hero-image.psd # Very large source file (binary, LFS) +├── icons/ +│ ├── navigation/ +│ │ ├── home.svg # SVG diffs as text +│ │ ├── settings.svg +│ │ └── history.svg +│ └── actions/ +│ ├── upload.svg +│ ├── generate.svg +│ └── compare.svg +├── design-tokens.json # Colors, typography, spacing — handoff to engineering +├── pipeline/ # AI generation pipeline (Kai's domain) +│ ├── model-params.yaml # Model configuration +│ ├── prompts/ +│ │ ├── sketch-to-ui.txt # Core generation prompt +│ │ ├── mobile-layout.txt # Mobile-specific prompt +│ │ └── accessibility-check.txt # Post-generation a11y validation prompt +│ └── training-data-manifest.json # References to training datasets +├── docs/ +│ ├── setup-guide.md +│ └── api-reference.md +├── CONTRIBUTING.md +├── CHANGELOG.md +├── .gitignore +└── .gitattributes +``` + +This structure ensures every chapter has realistic files to reference. Research artifacts are text-heavy (merge-friendly). Screen mockups and illustrations are binary (merge-hostile). Pipeline configs are structured text (hookable, validatable). The variety is intentional — it teaches Git's strengths and limitations simultaneously. + +--- + +## Chapter 1 — Research & Discovery + +Nora is a UX lead at a small startup. She's been running user research for a new product idea — an AI tool that turns rough sketches into polished prototypes. She has three weeks of interview notes, a competitive analysis, two persona documents, and a journey map. They live in a folder on her laptop called `sketchspark-research/`. + +One morning, her cloud sync overwrites the folder with a week-old version. Her latest interview findings, the revised competitive analysis, and the updated journey map are gone. She spends two days reconstructing what she can from memory and Slack messages. She never fully recovers the competitive analysis. + +A developer friend tells her: "This is exactly what Git solves." + +Nora installs Git. She learns what version control is — not through the history of Linux and BitKeeper, but through the pain of losing irreplaceable research. She learns that **centralized version control** is like her shared Google Drive: everyone connects to one place, and if it goes down or conflicts, work is lost. **Distributed version control** means every team member has the full history locally. If the cloud disappears tomorrow, her laptop still has everything. + +She learns the three states — modified, staged, committed — and maps them to her own workflow: +- **Modified**: she's updated the interview notes but hasn't marked them as ready +- **Staged**: she's selected which updates to bundle into a checkpoint +- **Committed**: the checkpoint is permanent — she can always come back to it + +She sets up her identity (`git config`) so her name appears on every checkpoint she creates. She asks: "Can I version my journey map PNGs and Sketch files?" The honest answer: Git handles them, but it can't show you what changed inside them the way it can with text. This limitation — binary vs. text — becomes a thread that runs through every chapter. + +--- + +## Chapter 2 — Concept Design + +Nora creates the SketchSpark repository. + +``` +cd sketchspark +git init +``` + +She adds the product brief, her persona documents, the competitive analysis, and the initial user flow. Each one is a markdown file — Git can track every word that changes. + +``` +git add product-brief.md research/personas/ research/competitive-analysis.md concept/user-flows.md +git commit -m "Add product brief, personas, competitive analysis, and initial user flows" +``` + +She learns the daily rhythm: check status, stage changes, write a commit message that explains *why* (not just *what*), review the log to see her project's history. She creates a `.gitignore` to exclude temp files her design tools generate: + +``` +.DS_Store +__MACOSX/ +*.sketch~ +*.figma_cache +Thumbs.db +``` + +She adds wireframe exports — PNGs of the sketch input screen and the results comparison screen. These are binary files. Git accepts them, but `git diff` shows nothing useful. She notes this and keeps going. + +She commits the wireframes separately from the text files — a habit she develops because text and binary changes serve different review purposes: + +``` +git add concept/wireframes/ +git commit -m "Add wireframes for sketch input and results comparison screens" +``` + +She explores the log. She uses `git log -S "5 options"` to find when she changed the product brief from "3 options" to "5 options" — tracing a design decision through history. + +She tags the milestone: + +``` +git tag -a v0.1-concept -m "Research complete, concept approved, entering UI exploration" +``` + +The concept phase is over. The product has a brief, personas, a competitive landscape, user flows, and wireframes — all versioned, all recoverable. + +--- + +## Chapter 3 — Parallel Exploration + +Sam joins the project. He's a UI designer who works fast. Nora brings him up to speed on the product brief and user flows, then asks him to explore layout directions for the results screen — the screen where users see their 5 generated options side by side. + +Sam's assignment mirrors the product itself: generate multiple options in parallel, then choose the best direction. + +He creates three branches: + +``` +git checkout -b option/card-layout +git checkout -b option/list-layout +git checkout -b option/canvas-freeform +``` + +Each branch contains a different approach to the same screen. On `option/card-layout`, the 5 options appear as cards in a grid. On `option/list-layout`, they stack vertically with detail panels. On `option/canvas-freeform`, they float on an infinite canvas the user can pan and zoom. + +While Sam explores, Nora continues refining the sketch input flow on `main`. She updates `concept/user-flows.md` to clarify the upload step. + +Sam, on `option/card-layout`, also edits `concept/user-flows.md` — he adds a "compare options" step that doesn't exist yet. Neither knows the other has touched the same file. + +Sam finishes the card layout and switches back to main: + +``` +git checkout main +git merge option/card-layout +``` + +**Conflict.** Both edited `concept/user-flows.md`. Git can't automatically reconcile Nora's upload clarification with Sam's new comparison step. They sit together, open the file, and see Git's conflict markers. They keep both changes — Nora's refined upload step *and* Sam's comparison step — in the right order. They commit the resolution. + +This is the team's first merge conflict. It's a text file, so the markers make sense. Nora notes: "If this had been a Figma file or a PSD, Git couldn't show us the conflict at all. We'd have to open both versions and manually compare." + +They establish branch naming conventions: +- `option/` — design explorations (may be discarded) +- `feature/` — approved work heading to production +- `fix/` — corrections to existing work +- `research/` — investigation branches (new interviews, usability tests) + +Mid-exploration, Nora discovers a critical flaw in the sketch input screen on `main` — the upload error state is missing. Sam is deep in `option/list-layout`. He creates a hotfix: + +``` +git stash +git checkout main +git checkout -b fix/sketch-input-upload-error +``` + +He designs the error state, commits, merges to main, then returns to his exploration: + +``` +git checkout option/list-layout +git stash pop +``` + +The team reviews all three options. They choose the card layout. Sam rebases the other two branches onto the latest main (which now includes the card layout merge) to see if any ideas from `list-layout` or `canvas-freeform` are worth carrying forward. They cherry-pick the "pinch-to-zoom on selected option" interaction from `canvas-freeform` into a new `feature/zoom-on-selection` branch. + +The exploration phase ends. One direction chosen, two archived, one idea salvaged. + +--- + +## Chapter 4 — Team Infrastructure + +The project has outgrown Nora's laptop. Sam needs access. They're about to bring on an illustrator. The repo needs a home. + +Nora evaluates options. Self-hosted Git servers are overkill for a three-person startup. GitHub offers pull request reviews, branch protection, project boards, and free private repos. GitLab has similar features but the team already has GitHub accounts. They go with GitHub. + +Nora creates the `sketchspark` organization and pushes the repo: + +``` +git remote add origin git@github.com:sketchspark/sketchspark.git +git push -u origin main +``` + +Sam needs SSH access. Nora walks him through key generation: "The `.pub` file is a badge — you give it to GitHub to prove who you are. The other file is your secret key. Never share it, never commit it." + +Nora configures branch protection on `main`: +- Pull requests required — no direct pushes +- At least one approval before merge +- Status checks must pass (they'll add these later) + +She sets up team roles: +- Nora: admin (manages settings, merges to main, handles releases) +- Sam: write (creates branches, opens PRs, pushes to feature branches) +- Stakeholders (the CEO, the lead engineer): read-only (view progress, leave comments on PRs) + +Sam opens his first pull request — the zoom-on-selection feature from the previous chapter. Nora reviews it on GitHub, leaves a comment asking for a loading state, Sam adds it, and Nora approves and merges. + +The team has infrastructure. Every change goes through review before reaching `main`. + +--- + +## Chapter 5 — Design & Build Sprint + +Two new people join. **Priya** is a concept designer and illustrator — she'll create SketchSpark's onboarding illustrations, the icon set, and high-fidelity marketing mockups. **Kai** is a frontend engineer who will build the AI generation pipeline, connecting the design work to the model that turns sketches into UI options. + +Four people. Four parallel workstreams: +- **Nora**: UX flows and research updates (text files) +- **Sam**: production UI screens for all core flows (Figma source + PNG exports) +- **Priya**: onboarding illustrations and icon set (large PNGs, SVGs, PSDs) +- **Kai**: AI pipeline configuration (YAML, prompt templates, JSON manifests) + +Each works on a feature branch: + +``` +nora: feature/ux-flows-v2 +sam: feature/production-screens +priya: feature/onboarding-illustrations +kai: feature/ai-pipeline-setup +``` + +Nora acts as integration manager. She reviews each PR before merging to `main`. The workflow: + +1. Designer creates branch, does work, pushes +2. Designer opens PR with description and screenshots +3. Nora reviews — for design work, this means checking screenshots, verifying flows, confirming token consistency +4. If approved, Nora merges to `main` + +Priya's first push takes three minutes. Her onboarding illustrations are 15-30MB each. The team discusses Git LFS but decides to revisit it later — for now, the repo is manageable. + +Sam creates `design-tokens.json` — the bridge between design and engineering. It contains colors, typography scales, spacing values, and border radii. Kai consumes these tokens in the frontend build. This file becomes one of the most frequently committed files in the repo, and the source of the most merge conflicts (everyone touches it). + +Kai sets up the `pipeline/` directory: `model-params.yaml` defines the AI model configuration, `prompts/sketch-to-ui.txt` is the core generation prompt, and `training-data-manifest.json` references the datasets. These are all text files — they diff cleanly, merge predictably, and can be validated with hooks. + +The sprint converges. The sketch-to-options pipeline works end to end for the first time: a user draws something, the model generates 5 UI options, and they appear in Sam's card layout. + +Nora tags the milestone: + +``` +git tag -a v0.5-alpha -m "Alpha: end-to-end sketch-to-options pipeline working" +``` + +She writes the first `CHANGELOG.md` entry and creates a release archive: + +``` +git archive main --prefix='sketchspark-v0.5-alpha/' --format=zip > sketchspark-v0.5-alpha.zip +``` + +The archive goes to the CEO for demo day. The alpha is alive. + +--- + +## Chapter 6 — Public Beta & Community + +The alpha demo goes well. The CEO wants a public beta. The repo goes from private to public on GitHub. + +Going public changes everything. Strangers will see the code, the prompts, the design files. Nora writes `CONTRIBUTING.md` — not for engineers, but for designers: + +- Prompt templates must follow the existing format (system context, then user instruction, then constraints) +- Illustrations must be 2x resolution, brand palette only, PNG export with transparent background +- Icons must sit on a 24x24 grid, 2px stroke, SVG format +- Screen mockups must include both light and dark mode +- All UI contributions must pass WCAG AA contrast requirements + +She expands `README.md` with screenshots of the product, a GIF showing the sketch-to-options flow, a component map, and links to the Figma source files. + +Then Marcus appears. He's a designer in Melbourne — 16 hours ahead of the team. He's been using the beta and thinks the mobile layout generation is weak. He forks the repo, creates `feature/mobile-prompt-template`, and edits `prompts/sketch-to-ui.txt` to add mobile-specific layout constraints. He also adds a new file: `prompts/mobile-layout.txt`. + +He opens a pull request. In the description, he includes before/after screenshots: five generated options from the same sketch, current vs. his improved prompt. The mobile options are noticeably better — less cramped, better touch target sizing. + +Nora reviews the PR the next morning. She's never met Marcus. She leaves feedback: +- The prompt improvement is strong, but the constraint format doesn't match the existing template +- The mobile-layout file needs a header comment explaining when the system uses it vs. the main prompt +- She suggests splitting the touch-target constraint into its own line for readability + +Marcus pushes updates. Nora approves and merges. The whole interaction happens asynchronously over 48 hours, entirely through GitHub comments and annotated screenshots. + +The team sets up GitHub Pages to host product documentation at `sketchspark.github.io` — setup guide, API reference, and contribution guidelines. + +Nora configures the GitHub organization: +- `@core-team`: Nora, Sam, Priya, Kai (write access to all repos) +- `@contributors`: Marcus and other external designers (fork-and-PR workflow) +- `@stakeholders`: CEO, investors (read-only, can comment on PRs) + +The product is no longer just theirs. + +--- + +## Chapter 7 — Production Hardening + +The beta has users. Bugs arrive. Complexity compounds. + +**Sam's stash.** Sam is midway through redesigning the results comparison screen — he's added a new "overlay diff" mode that lets users superimpose two generated options. Half the screens are done, half are placeholders. Then a bug report: the onboarding flow crashes on tablets. The layout breaks at 768px. + +Sam can't commit half-finished work to his branch (the placeholders would confuse reviewers). He stashes: + +``` +git stash push -m "WIP: overlay diff mode for results comparison" +``` + +He switches to `main`, creates `fix/onboarding-tablet-layout`, fixes the responsive breakpoint in the onboarding screens, commits, opens a PR, gets it reviewed, and merges. Then he returns: + +``` +git checkout feature/overlay-diff +git stash pop +``` + +His work-in-progress is exactly where he left it. + +**Priya's blame.** A stakeholder notices that the onboarding illustrations look "off" — the blue tones don't match the brand. Priya uses blame to trace the change: + +``` +git blame illustrations/onboarding/step-2-generate.png +``` + +The file is binary, so blame shows commit metadata but not visual content. She checks the log: + +``` +git log --oneline -- illustrations/onboarding/step-2-generate.png +``` + +Three commits ago, she exported from a file with the wrong color profile. She fixes the source, re-exports, and commits: `Fix color profile on onboarding illustrations (sRGB, not Display P3)`. + +**Nora's interactive staging.** Nora has been updating `product-brief.md` with two unrelated changes: a scope expansion (adding tablet support) and updated user interview findings from round 2. She wants to commit them separately — the scope change needs its own PR and approval, but the research update can merge immediately. + +``` +git add -p product-brief.md +``` + +She stages only the hunks related to interview findings, commits those, then stages and commits the scope expansion separately. Two clean commits instead of one muddled one. + +**Sam's accidental commit to main.** Sam forgets to create a branch. He commits a screen redesign directly to `main`. Branch protection catches it on push — he can't push to `main` without a PR. But the commit exists locally. He fixes it: + +``` +git reset --soft HEAD~1 +git checkout -b feature/screen-redesign +git commit -m "Redesign generation progress screen with loading animation" +``` + +The commit moves to the correct branch. `main` is clean. + +**Priya's messy history.** Priya's icon branch has five commits: + +``` +Add home icon +Fix home icon — wrong stroke width +Update home icon — adjust padding +Add settings icon +Fix settings icon — align to grid +``` + +Before opening her PR, she cleans up with interactive rebase: + +``` +git rebase -i HEAD~5 +``` + +She squashes the home icon commits into one ("Add home navigation icon") and the settings icon commits into one ("Add settings navigation icon"). The PR shows two clean additions instead of five noisy iterations. + +**Kai's submodule.** The AI pipeline has grown complex enough to be its own repository: `sketchspark-ml`. Kai adds it as a submodule of the main product repo: + +``` +git submodule add git@github.com:sketchspark/sketchspark-ml.git pipeline/ +``` + +When the model improves — better option variety, faster generation — Kai updates the submodule pointer in the main repo. The team pulls and gets the latest pipeline version without managing ML code directly. + +--- + +## Chapter 8 — Process & Automation + +The team has grown beyond informal coordination. They need guardrails. + +**Git attributes for binary files.** Nora creates `.gitattributes` to tell Git which files are binary and which can be meaningfully diffed: + +``` +# Binary — don't attempt to diff or merge +*.png binary +*.psd binary +*.fig binary +*.sketch binary + +# Text-based design files — diff normally +*.svg diff +*.md diff +*.json diff +*.yaml diff +*.txt diff + +# Large source files — version but exclude from archives +*.psd export-ignore +*.sketch export-ignore +research/raw-interviews/ export-ignore +``` + +This means `git diff` produces useful output for SVGs, tokens, prompts, and documentation — but doesn't try to diff PNGs or Figma files (which would just show binary garbage). + +**Commit message template.** Nora creates `.gitmessage`: + +``` +[Phase: Component] Short description + +# Phases: Research, Concept, Design, Pipeline, Docs, Fix, Release +# Examples: +# [Design: Results Screen] Add overlay diff comparison mode +# [Research: Persona] Update early-adopter goals after round 2 interviews +# [Pipeline: Prompts] Improve mobile layout generation constraints +# [Fix: Onboarding] Correct tablet breakpoint for step 2 illustration +``` + +She configures it: + +``` +git config commit.template .gitmessage +``` + +Every commit now starts from this template. The `[Phase: Component]` prefix makes `git log --oneline` scannable and `git log --grep="[Design:"` filters to design-only changes. + +**Pre-commit hook.** Nora adds a hook that runs before every commit: + +1. Validates `model-params.yaml` is syntactically correct YAML +2. Checks that prompt templates in `prompts/` don't exceed 4096 tokens (the model's context limit) +3. Warns (but doesn't block) if any PNG file exceeds 5MB + +The hook is a shell script — Nora found a template online and adapted it. She couldn't write it from scratch (she's not a programmer), but she can read it and modify the file size threshold. + +**Commit-msg hook.** A second hook validates that commit messages match the `[Phase: Component]` pattern. If Sam writes "fix stuff", the commit is rejected with a message explaining the expected format. + +**Image metadata diffing.** Nora configures Git to use `exiftool` for PNG diffs. Now `git diff` on an illustration shows metadata changes: dimensions, color profile, export date, DPI. It's not a visual diff, but it catches the color profile mistake that cost Priya time in Chapter 7. + +The team's process is now encoded in the repository itself. New contributors (like Marcus) inherit the rules automatically when they clone. + +--- + +## Chapter 9 — Legacy Migration + +SketchSpark acquires a smaller competitor, **QuickMock**. QuickMock has three years of design assets — mockups, illustrations, user research, and brand materials — stored in a Subversion (SVN) repository on a company server. + +Nora leads the migration. + +**Assessment.** She checks the SVN repo: 2,400 files, 1.2GB total. Most of the size comes from PSD source files (some over 100MB) and high-resolution marketing renders. The text files (research notes, documentation) are small and numerous. + +**Planning.** She decides: +- Import full history for text files (research, documentation, changelogs) — the evolution matters +- Import only the latest version of large binary files (PSDs, high-res PNGs) — old versions of 100MB PSDs aren't useful enough to justify the repo bloat +- Configure Git LFS for files over 10MB going forward +- Map QuickMock's flat folder structure to SketchSpark's organized hierarchy + +**Execution.** She uses `git svn clone` to pull the history: + +``` +git svn clone https://svn.quickmock.internal/trunk quickmock-import --authors-file=authors.txt +``` + +The authors file maps SVN usernames to Git identities so QuickMock's team gets proper attribution. + +Post-import cleanup: +- SVN branch names with `@` suffixes get cleaned up +- Large binaries get migrated to Git LFS: `git lfs migrate import --include="*.psd,*.ai" --above=10mb` +- QuickMock's flat `designs/` folder gets reorganized into SketchSpark's `screens/`, `illustrations/`, and `icons/` structure + +The migration takes a day. The combined repo is 800MB with LFS (down from 1.2GB if everything were inline). Three years of QuickMock's design evolution is now searchable alongside SketchSpark's history. + +Priya notes: "I wish we'd set up LFS from the start. My onboarding illustrations have been bloating the repo since Chapter 5." + +--- + +## Chapter 10 — Scale & Recovery + +It's two days before the v1.0 launch. The team is in final polish mode. Sam is updating screenshots in the documentation. Priya is exporting final marketing assets. Nora is writing release notes. Kai is tuning the model's generation speed. + +Then Sam makes a mistake. + +He means to reset his working directory to discard some local experiments. He types: + +``` +git reset --hard HEAD~3 +``` + +On `main`. He just rewound the main branch by three commits — Nora's release notes, Priya's final marketing illustrations, and Kai's generation speed improvement. All gone from `main`. + +Panic. Then Nora says: "Git doesn't delete anything. It just moves pointers." + +She opens the reflog: + +``` +git reflog +``` + +The reflog shows every position `HEAD` has been in. Three entries up, there's the commit before Sam's reset. She creates a recovery branch: + +``` +git branch recovery a1b2c3d +git checkout recovery +git log --oneline -5 +``` + +All three commits are there. She merges recovery into main: + +``` +git merge recovery +``` + +Everything is restored. The launch stays on schedule. + +This moment — the near-disaster and the recovery — becomes the frame for understanding Git internals: + +**Objects.** Every file version, every directory snapshot, every commit is stored as an object with a unique hash. Nora explains: "When you committed those release notes, Git created an object. When Sam reset `main`, Git didn't delete the object — it just moved the `main` label to point at an older one. The release notes object was still there, just unreachable through normal commands." + +**References.** Branches are labels. Tags are labels. HEAD is a label. Moving them — even destructively — doesn't destroy the underlying objects. Sam's `reset --hard` moved the `main` label backward. Nora's `branch recovery` created a new label pointing at the still-existing commit. + +**Reflog.** Git keeps a log of every label movement for at least 30 days. Even if Sam had deleted the branch, the reflog would still know where it pointed. The reflog is the safety net that makes Git's model robust against human error. + +**Packfiles.** Priya asks why `git clone` takes 45 seconds for a repo with thousands of files. Nora explains: Git packs similar objects together using delta compression. When Priya commits a slightly modified illustration, Git doesn't store a second full copy — it stores the difference. But very large binary files (her PSDs) resist delta compression, which is why LFS exists. + +The internals chapter isn't about cryptographic hash functions or the Git object database's implementation. It's about understanding *why your work is never truly lost* — and why that matters when months of research, design, and AI configuration are at stake. + +--- + +## Appendix A — Tooling Choices + +The team never agreed on one tool. That turned out fine. + +**Nora** uses the command line. Her work is text-heavy — product briefs, research notes, user flows. She types `git status`, `git diff`, `git log --oneline --graph` dozens of times a day. The CLI is fastest for her. + +**Sam** uses VS Code. He edits `design-tokens.json` and `user-flows.md` with Git's inline gutter indicators showing what changed since the last commit. The built-in source control panel lets him stage individual hunks without learning `git add -p` syntax. He reviews PRs with the GitHub Pull Requests extension. + +**Priya** uses GitHub Desktop. She stages files by checking boxes. She sees a visual list of changed files — critical when her commits include a dozen illustration exports. Drag-and-drop staging and clear binary file indicators ("This file has changed but can't be displayed") match how she thinks about her work. + +**Kai** uses JetBrains (WebStorm). The integrated terminal, diff viewer, and Git log sit alongside his Python and JavaScript code. He resolves merge conflicts in the three-pane merge tool without leaving his IDE. + +The appendix presents a decision tree: +- "I mainly write text and research documents" → CLI or VS Code +- "I work with lots of image files" → GitHub Desktop +- "I write code alongside design work" → VS Code or JetBrains +- "I want the simplest possible interface" → GitHub Desktop +- "I want maximum control" → CLI + +No choice is wrong. The best Git tool is the one you'll actually use. + +--- + +## Appendix B — Tool Integration + +Kai gives the team a look behind the curtain. + +SketchSpark's own architecture uses Git internally. When a user uploads a sketch and the system generates 5 UI options, each option is created as a lightweight branch in a temporary repository using **libgit2** (C library, called from the Python backend). The user's "compare options" screen is reading from Git branches. The "pick this one" button is a merge. The product's UX is a Git workflow — the user just never sees `git` commands. + +This reframing — "you've been using Git concepts all along without knowing it" — lands differently now that readers understand branches and merges from their own experience. + +Priya is intrigued by a different angle. She wants to automate her export workflow: every time she exports illustrations from her design tool, a script should auto-commit them to Git. She finds **Dulwich**, a Python Git library, and writes a script: + +```python +# Simplified — watches export folder and auto-commits new PNGs +from dulwich.repo import Repo +repo = Repo(".") +repo.stage(["illustrations/onboarding/step-1-upload.png"]) +repo.do_commit(b"Auto-export: updated onboarding illustration step 1") +``` + +It's ten lines of code (Kai helps with the details). Now her Git workflow is: export from design tool → script commits automatically → she opens a PR when the batch is ready. The manual `git add` / `git commit` cycle disappears for her binary file workflow. + +The appendix isn't about learning to write Git libraries. It's about understanding that the tools designers already use — GitHub Desktop, Figma plugins, CI/CD pipelines — are built on these libraries. Knowing they exist demystifies "how does GitHub Desktop work?" and opens the door to simple automation. + +--- + +## Appendix C — Reference + +The command reference is organized by SketchSpark workflow, not alphabetical command taxonomy. + +**Starting a Project** +- `git init` — Create a new repository (Nora in Chapter 2) +- `git clone` — Copy an existing repository (Sam joining in Chapter 3) +- `git config` — Set your name, email, editor, commit template (Chapter 1, Chapter 8) + +**Daily Design Work** +- `git status` — What's changed since my last commit? +- `git add` — Select files to include in the next commit +- `git add -p` — Select specific changes within a file (Nora in Chapter 7) +- `git commit` — Save a checkpoint with a message +- `git diff` — What exactly changed? (works for text files; limited for binary) +- `git stash` — Set aside work-in-progress temporarily (Sam in Chapter 7) + +**Exploring & Branching** +- `git branch` — List, create, or delete branches +- `git checkout` / `git switch` — Move to a different branch +- `git merge` — Combine one branch into another +- `git rebase` — Replay commits onto a different base (Sam in Chapter 3) + +**Collaborating** +- `git remote` — Manage connections to shared repositories +- `git push` — Send your commits to the shared repository +- `git pull` — Download and merge teammates' changes +- `git fetch` — Download without merging (check first, merge later) + +**Reviewing History** +- `git log` — See commit history (with `--oneline --graph` for visual overview) +- `git log -S "keyword"` — Find when a specific term was added or removed +- `git blame` — Find who last changed each line of a file (Priya in Chapter 7) +- `git show` — Display a specific commit's contents + +**Shipping a Release** +- `git tag` — Mark a commit as a release (v0.1-concept, v0.5-alpha, v1.0) +- `git archive` — Create a distributable zip/tar without Git history + +**Fixing Mistakes** +- `git restore` — Discard uncommitted changes to a file +- `git restore --staged` — Unstage a file without losing changes +- `git reset --soft HEAD~1` — Undo the last commit, keep changes staged (Sam in Chapter 7) +- `git revert` — Create a new commit that undoes a previous commit (safe for shared branches) +- `git reflog` — Find lost commits after a destructive operation (Nora in Chapter 10) + +**Maintaining Quality** +- `git clean` — Remove untracked files (caution: irreversible for design exports) +- `git lfs` — Manage large binary files (illustrations, PSDs) without bloating the repo + +Each command links back to the chapter where it appears in the storyline, so readers can revisit the full context. + +--- + +## Recurring Threads + +These themes weave through every chapter, creating continuity beyond the plot: + +**Binary vs. Text.** Introduced in Chapter 1 (Nora's question about Sketch files), demonstrated in Chapter 2 (wireframe PNGs vs. markdown briefs), painful in Chapter 5 (Priya's large illustrations), configured in Chapter 8 (`.gitattributes`), resolved in Chapter 9 (Git LFS). Every chapter reinforces: text files are Git's strength; binary files require extra care. + +**The Five Options.** The product generates 5 options from 1 sketch. Git creates parallel branches from 1 commit. This parallel is explicit in Chapter 3 (Sam's three `option/` branches), implicit in Chapter 5 (four parallel feature branches), and architectural in Appendix B (the product uses Git branches internally). The metaphor deepens as the reader's Git knowledge grows. + +**Design Decisions as Commits.** Every commit in the storyline represents a design decision — not a code change. "Update primary color for accessibility," "Add tablet breakpoint to onboarding," "Improve mobile generation prompt." This reframes Git from a developer tool to a design decision ledger. + +**Progressive Team Growth.** Chapter 1: solo. Chapter 2: solo with structure. Chapter 3: pair. Chapter 5: team of four. Chapter 6: open community. Each growth stage introduces the Git workflow that stage demands — tags when you're solo, branches when you're two, integration manager when you're four, fork-and-PR when you're open source. + +**The Safety Net.** Git's ability to recover from mistakes is introduced gently (undo in Chapter 2), tested (reset in Chapter 7), and fully proven (reflog recovery in Chapter 10). By the final chapter, the reader trusts that Git protects their work — the same trust that motivated Nora to adopt it after her file loss in Chapter 1. The story ends where it began: your work is never truly lost. diff --git a/.gemini/skills/sketchspark-author/references/voice.md b/.gemini/skills/sketchspark-author/references/voice.md new file mode 100644 index 000000000..0cf60d6e3 --- /dev/null +++ b/.gemini/skills/sketchspark-author/references/voice.md @@ -0,0 +1,30 @@ +# Voice and Tone Guide - Pro Git for UX Designers + +This guide defines how we speak to our audience: UX Designers, UI Designers, Product Designers, and researchers who may be new to Git and the Command Line. + +## Audience +- **Fluency:** Expert in design concepts (hierarchy, tokens, flows, research), novice in development infrastructure (Git, CLI, build pipelines). +- **Motivation:** Solving collaboration pain, preventing file loss, managing large design systems, contributing to open-source or engineering workflows. +- **Tools:** Figma, Sketch, Adobe Creative Cloud, GitHub Desktop, VS Code. + +## Tone +- **Professional but Approachable:** Speak like a senior peer, not a professor. +- **Empathetic:** Acknowledge the steep learning curve of the CLI. Avoid "simply," "obviously," or "just." +- **Visual:** Use visual metaphors. A branch is a parallel design exploration; a commit is a design checkpoint. +- **Practical:** Focus on "What does this mean for my design workflow?" rather than "How does this work in the Git internals?" (save internals for Chapter 10). + +## Writing Guidelines +- **Context before Syntax:** Explain *why* you are running a command and what you hope to achieve *before* showing the code block. +- **Narrative-Driven:** Use Nora, Sam, Priya, and Kai's story to ground every technical lesson in a realistic scenario. +- **Terminology:** + - **Commit:** A "checkpoint" or "snapshot" of the project's state. + - **Branch:** A "parallel exploration" or "version of the truth." + - **Merge:** "Integrating" or "reconciling" changes. + - **Staging Area:** The "selection" for the next checkpoint. +- **CLI Commands:** Always provide a brief breakdown of what each flag or argument does. + +## Character Voices +- **Nora (UX Lead):** Structured, methodical, process-oriented. Speaks in terms of research integrity and project health. +- **Sam (UI Designer):** Fast, experimental, sometimes messy. Asks the "what if I mess up?" questions. +- **Priya (Illustrator):** Focused on large assets, visual quality, and high-fidelity source files. Concerned about repo bloat and binary handling. +- **Kai (Engineer):** Bridges the gap. Explains the "why" behind the infrastructure in a way that relates to design tokens and model prompts. diff --git a/00-notes/conventions.md b/00-notes/conventions.md new file mode 100644 index 000000000..e933ca071 --- /dev/null +++ b/00-notes/conventions.md @@ -0,0 +1,56 @@ +# Cross-Chapter Conventions + +This document ensures consistency across the entire book. All walkthroughs and prose must adhere to these facts. + +## The SketchSpark Team +- **Nora:** UX Lead (CLI user) +- **Sam:** UI Designer (VS Code user) +- **Priya:** Illustrator (GitHub Desktop user) +- **Kai:** Frontend/ML Engineer (JetBrains user) +- **Marcus:** Community Contributor (fork-and-PR workflow) + +## Repository Structure +The repo name is always `sketchspark`. +``` +sketchspark/ +├── product-brief.md +├── research/ +├── concept/ +├── screens/ +├── illustrations/ +├── icons/ +├── design-tokens.json +├── pipeline/ +├── docs/ +├── CONTRIBUTING.md +├── CHANGELOG.md +├── .gitignore +└── .gitattributes +``` + +## Milestone Tags +- `v0.1-concept`: Concept approved, wireframes in place. +- `v0.5-alpha`: End-to-end pipeline working (web). +- `v0.8-beta`: Multi-platform, design token integration. +- `v1.0`: Public launch, refinement editor. + +## Standard Branch Names +- `main`: The stable version of the truth. +- `option/<name>`: Design explorations (e.g., `option/card-layout`). +- `feature/<name>`: Approved work (e.g., `feature/onboarding-illustrations`). +- `fix/<name>`: Corrections (e.g., `fix/contrast-audit`). +- `research/<name>`: Discovery work. + +## Commit Message Format +The team uses a `[Phase: Component]` prefix: +- `[Design: Results Screen] Add overlay diff comparison mode` +- `[Research: Persona] Update early-adopter goals` +- `[Pipeline: Prompts] Improve mobile layout generation` +- `[Fix: Onboarding] Correct tablet breakpoint` + +## Key File Ownership +- `product-brief.md`, `research/`: Owned by Nora. +- `screens/`, `design-tokens.json`: Owned by Sam. +- `illustrations/`, `icons/`: Owned by Priya. +- `pipeline/`: Owned by Kai. +- `prompts/`: Edited by Kai and Marcus. diff --git a/00-notes/voice-and-tone.md b/00-notes/voice-and-tone.md new file mode 100644 index 000000000..0cf60d6e3 --- /dev/null +++ b/00-notes/voice-and-tone.md @@ -0,0 +1,30 @@ +# Voice and Tone Guide - Pro Git for UX Designers + +This guide defines how we speak to our audience: UX Designers, UI Designers, Product Designers, and researchers who may be new to Git and the Command Line. + +## Audience +- **Fluency:** Expert in design concepts (hierarchy, tokens, flows, research), novice in development infrastructure (Git, CLI, build pipelines). +- **Motivation:** Solving collaboration pain, preventing file loss, managing large design systems, contributing to open-source or engineering workflows. +- **Tools:** Figma, Sketch, Adobe Creative Cloud, GitHub Desktop, VS Code. + +## Tone +- **Professional but Approachable:** Speak like a senior peer, not a professor. +- **Empathetic:** Acknowledge the steep learning curve of the CLI. Avoid "simply," "obviously," or "just." +- **Visual:** Use visual metaphors. A branch is a parallel design exploration; a commit is a design checkpoint. +- **Practical:** Focus on "What does this mean for my design workflow?" rather than "How does this work in the Git internals?" (save internals for Chapter 10). + +## Writing Guidelines +- **Context before Syntax:** Explain *why* you are running a command and what you hope to achieve *before* showing the code block. +- **Narrative-Driven:** Use Nora, Sam, Priya, and Kai's story to ground every technical lesson in a realistic scenario. +- **Terminology:** + - **Commit:** A "checkpoint" or "snapshot" of the project's state. + - **Branch:** A "parallel exploration" or "version of the truth." + - **Merge:** "Integrating" or "reconciling" changes. + - **Staging Area:** The "selection" for the next checkpoint. +- **CLI Commands:** Always provide a brief breakdown of what each flag or argument does. + +## Character Voices +- **Nora (UX Lead):** Structured, methodical, process-oriented. Speaks in terms of research integrity and project health. +- **Sam (UI Designer):** Fast, experimental, sometimes messy. Asks the "what if I mess up?" questions. +- **Priya (Illustrator):** Focused on large assets, visual quality, and high-fidelity source files. Concerned about repo bloat and binary handling. +- **Kai (Engineer):** Bridges the gap. Explains the "why" behind the infrastructure in a way that relates to design tokens and model prompts. diff --git a/B-embedding-git-in-your-applications.asc b/B-embedding-git-in-your-applications.asc index f3e602979..a6b9ddbfe 100644 --- a/B-embedding-git-in-your-applications.asc +++ b/B-embedding-git-in-your-applications.asc @@ -2,11 +2,9 @@ [appendix] == Embedding Git in your Applications -If your application is for developers, chances are good that it could benefit from integration with source control. -Even non-developer applications, such as document editors, could potentially benefit from version-control features, and Git's model works very well for many different scenarios. +If you are building a tool for designers—like the SketchSpark app—chances are good that you need to handle versions, parallel explorations, and team synchronization. Instead of reinventing the wheel, you can use Git as your application's "versioning engine." -If you need to integrate Git with your application, you have essentially two options: spawn a shell and call the `git` command-line program, or embed a Git library into your application. -Here we'll cover command-line integration and several of the most popular embeddable Git libraries. +Many modern design tools (like Figma, Abstract, or Kactus) use Git or Git-like models under the hood. In this appendix, we’ll look at the technical ways you can integrate Git directly into your own software, from simple command-line automation to embedding high-performance libraries like **Libgit2**. include::book/B-embedding-git/sections/command-line.asc[] diff --git a/C-git-commands.asc b/C-git-commands.asc index 3e3523ef7..5c02c763b 100644 --- a/C-git-commands.asc +++ b/C-git-commands.asc @@ -2,580 +2,68 @@ [appendix] == Git Commands -Throughout the book we have introduced dozens of Git commands and have tried hard to introduce them within something of a narrative, adding more commands to the story slowly. -However, this leaves us with examples of usage of the commands somewhat scattered throughout the whole book. +Throughout this book, we’ve introduced dozens of Git commands within the narrative of Nora and the SketchSpark team. This appendix serves as a quick reference for those commands, organized by their role in your design workflow. -In this appendix, we'll go through all the Git commands we addressed throughout the book, grouped roughly by what they're used for. -We'll talk about what each command very generally does and then point out where in the book you can find us having used it. +For each command, we provide a brief summary and a link back to the section where it was first introduced or explained in detail. -[TIP] -==== -You can abbreviate long options. -For example, you can type in `git commit --a`, which acts as if you typed `git commit --amend`. -This only works when the letters after `--` are unique for one option. -Do use the full option when writing scripts. -==== +### Project Setup and Configuration -=== Setup and Config +These commands are used to tailor Git to your personal and team conventions. -There are two commands that are used quite a lot, from the first invocations of Git to common every day tweaking and referencing, the `config` and `help` commands. +* **`git config`**: The master switch for your Git settings. Used to set your identity (Chapter 1), create aliases (Chapter 2), and set up global ignores and commit templates (Chapter 8). +* **`git help`**: Your primary resource for technical details. Access comprehensive manuals for any command (e.g., `git help commit`) (Chapter 1). -==== git config +### Getting and Creating Projects -Git has a default way of doing hundreds of things. -For a lot of these things, you can tell Git to default to doing them a different way, or set your preferences. -This involves everything from telling Git what your name is to specific terminal color preferences or what editor you use. -There are several files this command will read from and write to so you can set values globally or down to specific repositories. +How Nora and Sam start new repositories or join existing ones. -The `git config` command has been used in nearly every chapter of the book. +* **`git init`**: Turns a local folder (like Nora’s research directory) into a real Git repository (Chapter 2). +* **`git clone`**: The standard way to get a full copy of a project from a server like GitHub (Chapter 2). -In <<ch01-getting-started#_first_time>> we used it to specify our name, email address and editor preference before we even got started using Git. +### Daily Design Rhythms -In <<ch02-git-basics-chapter#_git_aliases>> we showed how you could use it to create shorthand commands that expand to long option sequences so you don't have to type them every time. +The core commands Nora and Sam use every hour to track their progress. -In <<ch03-git-branching#_rebasing>> we used it to make `--rebase` the default when you run `git pull`. +* **`git status`**: The first command you should run. Shows which files are modified, staged, or untracked (Chapter 2). +* **`git add`**: Selects changes for your next "design checkpoint." Includes `git add -p` for selective "patch" staging (Chapter 2, Chapter 7). +* **`git diff`**: Shows exactly what changed in your research or design tokens. Use `--staged` to see what’s ready for a commit (Chapter 2, Chapter 7). +* **`git commit`**: Creates a permanent snapshot (checkpoint) in the project’s history. Use `--amend` to fix your most recent mistake (Chapter 2). +* **`git stash`**: A "pause button" for your creative flow. Tucks away unfinished work so you can switch to another task (Chapter 7). -In <<ch07-git-tools#_credential_caching>> we used it to set up a default store for your HTTP passwords. +### Managing Explorations (Branching & Merging) -In <<ch08-customizing-git#_keyword_expansion>> we showed how to set up smudge and clean filters on content coming in and out of Git. +How the team handles parallel ideas and reconciles them. -Finally, basically the entirety of <<ch08-customizing-git#_git_config>> is dedicated to the command. +* **`git branch`**: Lists, creates, and deletes your "parallel explorations." Use `-v` to see the latest checkpoint on each branch (Chapter 3). +* **`git checkout`**: (or `git switch`) Moves you between branches. Use `-b` to create and switch in one step (Chapter 3). +* **`git merge`**: Integrates an exploration (like Sam’s `option/card-layout`) back into the main project (Chapter 3). +* **`git rebase`**: Replays your work on top of another branch to create a cleaner, linear history. Use `-i` to curate and "squash" your local history before sharing (Chapter 3, Chapter 7). +* **`git tag`**: Marks important milestones like `v0.1-concept` or `v1.0-launch` (Chapter 2, Chapter 5). -[[ch_core_editor]] -==== git config core.editor commands +### Collaboration & GitHub -Accompanying the configuration instructions in <<ch01-getting-started#_editor>>, many editors can be set as follows: +How the team synchronizes their work across the world. -.Exhaustive list of `core.editor` configuration commands -[cols="1,2",options="header"] -|============================== -|Editor | Configuration command -|Atom |`git config --global core.editor "atom --wait"` -|BBEdit (macOS, with command line tools) |`git config --global core.editor "bbedit -w"` -|Emacs |`git config --global core.editor emacs` -|Gedit (Linux) |`git config --global core.editor "gedit --wait --new-window"` -|Gvim (Windows 64-bit) |`git config --global core.editor "'C:\Program Files\Vim\vim72\gvim.exe' --nofork '%*'"` (Also see note below) -|Helix |`git config --global core.editor "hx"` -|Kate (Linux) |`git config --global core.editor "kate --block"` -|nano |`git config --global core.editor "nano -w"` -|Notepad (Windows 64-bit) |`git config core.editor notepad` -|Notepad++ (Windows 64-bit) |`git config --global core.editor "'C:\Program Files\Notepad+\+\notepad++.exe' -multiInst -notabbar -nosession -noPlugin"` (Also see note below) -|Scratch (Linux)|`git config --global core.editor "scratch-text-editor"` -|Sublime Text (macOS) |`git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl --new-window --wait"` -|Sublime Text (Windows 64-bit) |`git config --global core.editor "'C:\Program Files\Sublime Text 3\sublime_text.exe' -w"` (Also see note below) -|TextEdit (macOS)|`git config --global core.editor "open --wait-apps --new -e"` -|Textmate |`git config --global core.editor "mate -w"` -|Textpad (Windows 64-bit) |`git config --global core.editor "'C:\Program Files\TextPad 5\TextPad.exe' -m"` (Also see note below) -|UltraEdit (Windows 64-bit) | `git config --global core.editor Uedit32` -|Vim |`git config --global core.editor "vim --nofork"` -|Visual Studio Code |`git config --global core.editor "code --wait"` -|VSCodium (Free/Libre Open Source Software Binaries of VSCode) | `git config --global core.editor "codium --wait"` -|WordPad |`git config --global core.editor "'C:\Program Files\Windows NT\Accessories\wordpad.exe'"` -|Xi | `git config --global core.editor "xi --wait"` -|============================== +* **`git remote`**: Manages your connections to shared servers like GitHub (Chapter 2). +* **`git fetch`**: Downloads the latest work from your teammates without merging it into your local copies (Chapter 3, Chapter 5). +* **`git pull`**: The "morning ritual." Fetches your team’s latest changes and immediately merges them into your current branch (Chapter 3, Chapter 5). +* **`git push`**: Publishes your approved checkpoints to the shared team server (Chapter 2, Chapter 5). -[NOTE] -==== -If you have a 32-bit editor on a Windows 64-bit system, the program will be installed in `C:\Program Files (x86)\` rather than `C:\Program Files\` as in the table above. -==== +### History & Auditing -==== git help +How Nora traces design decisions and recovers lost work. -The `git help` command is used to show you all the documentation shipped with Git about any command. -While we're giving a rough overview of most of the more popular ones in this appendix, for a full listing of all of the possible options and flags for every command, you can always run `git help <command>`. +* **`git log`**: The "ledger of decisions." Shows the project’s history. Includes `-S` for searching specific text changes and `-L` for tracing the evolution of a single line (Chapter 2, Chapter 7). +* **`git show`**: Displays the full details of a specific commit or tag (Chapter 2). +* **`git blame`**: Shows who last touched each line of a file—essential for finding the right person for a design crit (Chapter 7). +* **`git grep`**: A lightning-fast search for terms inside your entire design archive (Chapter 7). +* **`git reflog`**: The ultimate safety net. Records every move you’ve made, allowing you to recover "deleted" work (Chapter 7, Chapter 10). -We introduced the `git help` command in <<ch01-getting-started#_git_help>> and showed you how to use it to find more information about the `git shell` in <<ch04-git-on-the-server#_setting_up_server>>. +### Recovery & Maintenance -=== Getting and Creating Projects +Commands for tidying up and fixing complex issues. -There are two ways to get a Git repository. -One is to copy it from an existing repository on the network or elsewhere and the other is to create a new one in an existing directory. - -==== git init - -To take a directory and turn it into a new Git repository so you can start version controlling it, you can simply run `git init`. - -We first introduce this in <<ch02-git-basics-chapter#_getting_a_repo>>, where we show creating a brand new repository to start working with. - -We talk briefly about how you can change the default branch name from "`master`" in <<ch03-git-branching#_remote_branches>>. - -We use this command to create an empty bare repository for a server in <<ch04-git-on-the-server#_bare_repo>>. - -Finally, we go through some of the details of what it actually does behind the scenes in <<ch10-git-internals#_plumbing_porcelain>>. - -==== git clone - -The `git clone` command is actually something of a wrapper around several other commands. -It creates a new directory, goes into it and runs `git init` to make it an empty Git repository, adds a remote (`git remote add`) to the URL that you pass it (by default named `origin`), runs a `git fetch` from that remote repository and then checks out the latest commit into your working directory with `git checkout`. - -The `git clone` command is used in dozens of places throughout the book, but we'll just list a few interesting places. - -It's basically introduced and explained in <<ch02-git-basics-chapter#_git_cloning>>, where we go through a few examples. - -In <<ch04-git-on-the-server#_getting_git_on_a_server>> we look at using the `--bare` option to create a copy of a Git repository with no working directory. - -In <<ch07-git-tools#_bundling>> we use it to unbundle a bundled Git repository. - -Finally, in <<ch07-git-tools#_cloning_submodules>> we learn the `--recurse-submodules` option to make cloning a repository with submodules a little simpler. - -Though it's used in many other places through the book, these are the ones that are somewhat unique or where it is used in ways that are a little different. - -=== Basic Snapshotting - -For the basic workflow of staging content and committing it to your history, there are only a few basic commands. - -==== git add - -The `git add` command adds content from the working directory into the staging area (or "`index`") for the next commit. -When the `git commit` command is run, by default it only looks at this staging area, so `git add` is used to craft what exactly you would like your next commit snapshot to look like. - -This command is an incredibly important command in Git and is mentioned or used dozens of times in this book. -We'll quickly cover some of the unique uses that can be found. - -We first introduce and explain `git add` in detail in <<ch02-git-basics-chapter#_tracking_files>>. - -We mention how to use it to resolve merge conflicts in <<ch03-git-branching#_basic_merge_conflicts>>. - -We go over using it to interactively stage only specific parts of a modified file in <<ch07-git-tools#_interactive_staging>>. - -Finally, we emulate it at a low level in <<ch10-git-internals#_tree_objects>>, so you can get an idea of what it's doing behind the scenes. - -==== git status - -The `git status` command will show you the different states of files in your working directory and staging area. -Which files are modified and unstaged and which are staged but not yet committed. -In its normal form, it also will show you some basic hints on how to move files between these stages. - -We first cover `status` in <<ch02-git-basics-chapter#_checking_status>>, both in its basic and simplified forms. -While we use it throughout the book, pretty much everything you can do with the `git status` command is covered there. - -==== git diff - -The `git diff` command is used when you want to see differences between any two trees. -This could be the difference between your working environment and your staging area (`git diff` by itself), between your staging area and your last commit (`git diff --staged`), or between two commits (`git diff master branchB`). - -We first look at the basic uses of `git diff` in <<ch02-git-basics-chapter#_git_diff_staged>>, where we show how to see what changes are staged and which are not yet staged. - -We use it to look for possible whitespace issues before committing with the `--check` option in <<ch05-distributed-git#_commit_guidelines>>. - -We see how to check the differences between branches more effectively with the `git diff A...B` syntax in <<ch05-distributed-git#_what_is_introduced>>. - -We use it to filter out whitespace differences with `-b` and how to compare different stages of conflicted files with `--theirs`, `--ours` and `--base` in <<ch07-git-tools#_advanced_merging>>. - -Finally, we use it to effectively compare submodule changes with `--submodule` in <<ch07-git-tools#_starting_submodules>>. - -==== git difftool - -The `git difftool` command simply launches an external tool to show you the difference between two trees in case you want to use something other than the built in `git diff` command. - -We only briefly mention this in <<ch02-git-basics-chapter#_git_diff_staged>>. - -==== git commit - -The `git commit` command takes all the file contents that have been staged with `git add` and records a new permanent snapshot in the database and then moves the branch pointer on the current branch up to it. - -We first cover the basics of committing in <<ch02-git-basics-chapter#_committing_changes>>. -There we also demonstrate how to use the `-a` flag to skip the `git add` step in daily workflows and how to use the `-m` flag to pass a commit message in on the command line instead of firing up an editor. - -In <<ch02-git-basics-chapter#_undoing>> we cover using the `--amend` option to redo the most recent commit. - -In <<ch03-git-branching#_git_branches_overview>>, we go into much more detail about what `git commit` does and why it does it like that. - -We looked at how to sign commits cryptographically with the `-S` flag in <<ch07-git-tools#_signing_commits>>. - -Finally, we take a look at what the `git commit` command does in the background and how it's actually implemented in <<ch10-git-internals#_git_commit_objects>>. - -==== git reset - -The `git reset` command is primarily used to undo things, as you can possibly tell by the verb. -It moves around the `HEAD` pointer and optionally changes the `index` or staging area and can also optionally change the working directory if you use `--hard`. -This final option makes it possible for this command to lose your work if used incorrectly, so make sure you understand it before using it. - -We first effectively cover the simplest use of `git reset` in <<ch02-git-basics-chapter#_unstaging>>, where we use it to unstage a file we had run `git add` on. - -We then cover it in quite some detail in <<ch07-git-tools#_git_reset>>, which is entirely devoted to explaining this command. - -We use `git reset --hard` to abort a merge in <<ch07-git-tools#_abort_merge>>, where we also use `git merge --abort`, which is a bit of a wrapper for the `git reset` command. - -==== git rm - -The `git rm` command is used to remove files from the staging area and working directory for Git. -It is similar to `git add` in that it stages a removal of a file for the next commit. - -We cover the `git rm` command in some detail in <<ch02-git-basics-chapter#_removing_files>>, including recursively removing files and only removing files from the staging area but leaving them in the working directory with `--cached`. - -The only other differing use of `git rm` in the book is in <<ch10-git-internals#_removing_objects>> where we briefly use and explain the `--ignore-unmatch` when running `git filter-branch`, which simply makes it not error out when the file we are trying to remove doesn't exist. -This can be useful for scripting purposes. - -==== git mv - -The `git mv` command is a thin convenience command to move a file and then run `git add` on the new file and `git rm` on the old file. - -We only briefly mention this command in <<ch02-git-basics-chapter#_git_mv>>. - -==== git clean - -The `git clean` command is used to remove unwanted files from your working directory. -This could include removing temporary build artifacts or merge conflict files. - -We cover many of the options and scenarios in which you might used the clean command in <<ch07-git-tools#_git_clean>>. - -=== Branching and Merging - -There are just a handful of commands that implement most of the branching and merging functionality in Git. - -==== git branch - -The `git branch` command is actually something of a branch management tool. -It can list the branches you have, create a new branch, delete branches and rename branches. - -Most of <<ch03-git-branching#ch03-git-branching>> is dedicated to the `branch` command and it's used throughout the entire chapter. -We first introduce it in <<ch03-git-branching#_create_new_branch>> and we go through most of its other features (listing and deleting) in <<ch03-git-branching#_branch_management>>. - -In <<ch03-git-branching#_tracking_branches>> we use the `git branch -u` option to set up a tracking branch. - -Finally, we go through some of what it does in the background in <<ch10-git-internals#_git_refs>>. - -==== git checkout - -The `git checkout` command is used to switch branches and check content out into your working directory. - -We first encounter the command in <<ch03-git-branching#_switching_branches>> along with the `git branch` command. - -We see how to use it to start tracking branches with the `--track` flag in <<ch03-git-branching#_tracking_branches>>. - -We use it to reintroduce file conflicts with `--conflict=diff3` in <<ch07-git-tools#_checking_out_conflicts>>. - -We go into closer detail on its relationship with `git reset` in <<ch07-git-tools#_git_reset>>. - -Finally, we go into some implementation detail in <<ch10-git-internals#ref_the_ref>>. - -==== git merge - -The `git merge` tool is used to merge one or more branches into the branch you have checked out. -It will then advance the current branch to the result of the merge. - -The `git merge` command was first introduced in <<ch03-git-branching#_basic_branching>>. -Though it is used in various places in the book, there are very few variations of the `merge` command -- generally just `git merge <branch>` with the name of the single branch you want to merge in. - -We covered how to do a squashed merge (where Git merges the work but pretends like it's just a new commit without recording the history of the branch you're merging in) at the very end of <<ch05-distributed-git#_public_project>>. - -We went over a lot about the merge process and command, including the `-Xignore-space-change` command and the `--abort` flag to abort a problem merge in <<ch07-git-tools#_advanced_merging>>. - -We learned how to verify signatures before merging if your project is using GPG signing in <<ch07-git-tools#_signing_commits>>. - -Finally, we learned about Subtree merging in <<ch07-git-tools#_subtree_merge>>. - -==== git mergetool - -The `git mergetool` command simply launches an external merge helper in case you have issues with a merge in Git. - -We mention it quickly in <<ch03-git-branching#_basic_merge_conflicts>> and go into detail on how to implement your own external merge tool in <<ch08-customizing-git#_external_merge_tools>>. - -==== git log - -The `git log` command is used to show the reachable recorded history of a project from the most recent commit snapshot backwards. -By default it will only show the history of the branch you're currently on, but can be given different or even multiple heads or branches from which to traverse. -It is also often used to show differences between two or more branches at the commit level. - -This command is used in nearly every chapter of the book to demonstrate the history of a project. - -We introduce the command and cover it in some depth in <<ch02-git-basics-chapter#_viewing_history>>. -There we look at the `-p` and `--stat` option to get an idea of what was introduced in each commit and the `--pretty` and `--oneline` options to view the history more concisely, along with some simple date and author filtering options. - -In <<ch03-git-branching#_create_new_branch>> we use it with the `--decorate` option to easily visualize where our branch pointers are located and we also use the `--graph` option to see what divergent histories look like. - -In <<ch05-distributed-git#_private_team>> and <<ch07-git-tools#_commit_ranges>> we cover the `branchA..branchB` syntax to use the `git log` command to see what commits are unique to a branch relative to another branch. -In <<ch07-git-tools#_commit_ranges>> we go through this fairly extensively. - -In <<ch07-git-tools#_merge_log>> and <<ch07-git-tools#_triple_dot>> we cover using the `branchA...branchB` format and the `--left-right` syntax to see what is in one branch or the other but not in both. -In <<ch07-git-tools#_merge_log>> we also look at how to use the `--merge` option to help with merge conflict debugging as well as using the `--cc` option to look at merge commit conflicts in your history. - -In <<ch07-git-tools#_git_reflog>> we use the `-g` option to view the Git reflog through this tool instead of doing branch traversal. - -In <<ch07-git-tools#_searching>> we look at using the `-S` and `-L` options to do fairly sophisticated searches for something that happened historically in the code such as seeing the history of a function. - -In <<ch07-git-tools#_signing_commits>> we see how to use `--show-signature` to add a validation string to each commit in the `git log` output based on if it was validly signed or not. - -==== git stash - -The `git stash` command is used to temporarily store uncommitted work in order to clean out your working directory without having to commit unfinished work on a branch. - -This is basically entirely covered in <<ch07-git-tools#_git_stashing>>. - -==== git tag - -The `git tag` command is used to give a permanent bookmark to a specific point in the code history. -Generally this is used for things like releases. - -This command is introduced and covered in detail in <<ch02-git-basics-chapter#_git_tagging>> and we use it in practice in <<ch05-distributed-git#_tagging_releases>>. - -We also cover how to create a GPG signed tag with the `-s` flag and verify one with the `-v` flag in <<ch07-git-tools#_signing>>. - -=== Sharing and Updating Projects - -There are not very many commands in Git that access the network, nearly all of the commands operate on the local database. -When you are ready to share your work or pull changes from elsewhere, there are a handful of commands that deal with remote repositories. - -==== git fetch - -The `git fetch` command communicates with a remote repository and fetches down all the information that is in that repository that is not in your current one and stores it in your local database. - -We first look at this command in <<ch02-git-basics-chapter#_fetching_and_pulling>> and we continue to see examples of its use in <<ch03-git-branching#_remote_branches>>. - -We also use it in several of the examples in <<ch05-distributed-git#_contributing_project>>. - -We use it to fetch a single specific reference that is outside of the default space in <<ch06-github#_pr_refs>> and we see how to fetch from a bundle in <<ch07-git-tools#_bundling>>. - -We set up highly custom refspecs in order to make `git fetch` do something a little different than the default in <<ch10-git-internals#_refspec>>. - -==== git pull - -The `git pull` command is basically a combination of the `git fetch` and `git merge` commands, where Git will fetch from the remote you specify and then immediately try to merge it into the branch you're on. - -We introduce it quickly in <<ch02-git-basics-chapter#_fetching_and_pulling>> and show how to see what it will merge if you run it in <<ch02-git-basics-chapter#_inspecting_remote>>. - -We also see how to use it to help with rebasing difficulties in <<ch03-git-branching#_rebase_rebase>>. - -We show how to use it with a URL to pull in changes in a one-off fashion in <<ch05-distributed-git#_checking_out_remotes>>. - -Finally, we very quickly mention that you can use the `--verify-signatures` option to it in order to verify that commits you are pulling have been GPG signed in <<ch07-git-tools#_signing_commits>>. - -==== git push - -The `git push` command is used to communicate with another repository, calculate what your local database has that the remote one does not, and then pushes the difference into the other repository. -It requires write access to the other repository and so normally is authenticated somehow. - -We first look at the `git push` command in <<ch02-git-basics-chapter#_pushing_remotes>>. -Here we cover the basics of pushing a branch to a remote repository. -In <<ch03-git-branching#_pushing_branches>> we go a little deeper into pushing specific branches and in <<ch03-git-branching#_tracking_branches>> we see how to set up tracking branches to automatically push to. -In <<ch03-git-branching#_delete_branches>> we use the `--delete` flag to delete a branch on the server with `git push`. - -Throughout <<ch05-distributed-git#_contributing_project>> we see several examples of using `git push` to share work on branches through multiple remotes. - -We see how to use it to share tags that you have made with the `--tags` option in <<ch02-git-basics-chapter#_sharing_tags>>. - -In <<ch07-git-tools#_publishing_submodules>> we use the `--recurse-submodules` option to check that all of our submodules work has been published before pushing the superproject, which can be really helpful when using submodules. - -In <<ch08-customizing-git#_other_client_hooks>> we talk briefly about the `pre-push` hook, which is a script we can setup to run before a push completes to verify that it should be allowed to push. - -Finally, in <<ch10-git-internals#_pushing_refspecs>> we look at pushing with a full refspec instead of the general shortcuts that are normally used. -This can help you be very specific about what work you wish to share. - -==== git remote - -The `git remote` command is a management tool for your record of remote repositories. -It allows you to save long URLs as short handles, such as "`origin`" so you don't have to type them out all the time. -You can have several of these and the `git remote` command is used to add, change and delete them. - -This command is covered in detail in <<ch02-git-basics-chapter#_remote_repos>>, including listing, adding, removing and renaming them. - -It is used in nearly every subsequent chapter in the book too, but always in the standard `git remote add <name> <url>` format. - -==== git archive - -The `git archive` command is used to create an archive file of a specific snapshot of the project. - -We use `git archive` to create a tarball of a project for sharing in <<ch05-distributed-git#_preparing_release>>. - -==== git submodule - -The `git submodule` command is used to manage external repositories within a normal repositories. -This could be for libraries or other types of shared resources. -The `submodule` command has several sub-commands (`add`, `update`, `sync`, etc) for managing these resources. - -This command is only mentioned and entirely covered in <<ch07-git-tools#_git_submodules>>. - -=== Inspection and Comparison - -==== git show - -The `git show` command can show a Git object in a simple and human readable way. -Normally you would use this to show the information about a tag or a commit. - -We first use it to show annotated tag information in <<ch02-git-basics-chapter#_annotated_tags>>. - -Later we use it quite a bit in <<ch07-git-tools#_revision_selection>> to show the commits that our various revision selections resolve to. - -One of the more interesting things we do with `git show` is in <<ch07-git-tools#_manual_remerge>> to extract specific file contents of various stages during a merge conflict. - -==== git shortlog - -The `git shortlog` command is used to summarize the output of `git log`. -It will take many of the same options that the `git log` command will but instead of listing out all of the commits it will present a summary of the commits grouped by author. - -We showed how to use it to create a nice changelog in <<ch05-distributed-git#_the_shortlog>>. - -==== git describe - -The `git describe` command is used to take anything that resolves to a commit and produces a string that is somewhat human-readable and will not change. -It's a way to get a description of a commit that is as unambiguous as a commit SHA-1 but more understandable. - -We use `git describe` in <<ch05-distributed-git#_build_number>> and <<ch05-distributed-git#_preparing_release>> to get a string to name our release file after. - -=== Debugging - -Git has a couple of commands that are used to help debug an issue in your code. -This ranges from figuring out where something was introduced to figuring out who introduced it. - -==== git bisect - -The `git bisect` tool is an incredibly helpful debugging tool used to find which specific commit was the first one to introduce a bug or problem by doing an automatic binary search. - -It is fully covered in <<ch07-git-tools#_binary_search>> and is only mentioned in that section. - -==== git blame - -The `git blame` command annotates the lines of any file with which commit was the last one to introduce a change to each line of the file and what person authored that commit. -This is helpful in order to find the person to ask for more information about a specific section of your code. - -It is covered in <<ch07-git-tools#_file_annotation>> and is only mentioned in that section. - -==== git grep - -The `git grep` command can help you find any string or regular expression in any of the files in your source code, even older versions of your project. - -It is covered in <<ch07-git-tools#_git_grep>> and is only mentioned in that section. - -=== Patching - -A few commands in Git are centered around the concept of thinking of commits in terms of the changes they introduce, as though the commit series is a series of patches. -These commands help you manage your branches in this manner. - -==== git cherry-pick - -The `git cherry-pick` command is used to take the change introduced in a single Git commit and try to re-introduce it as a new commit on the branch you're currently on. -This can be useful to only take one or two commits from a branch individually rather than merging in the branch which takes all the changes. - -Cherry picking is described and demonstrated in <<ch05-distributed-git#_rebase_cherry_pick>>. - -==== git rebase - -The `git rebase` command is basically an automated `cherry-pick`. -It determines a series of commits and then cherry-picks them one by one in the same order somewhere else. - -Rebasing is covered in detail in <<ch03-git-branching#_rebasing>>, including covering the collaborative issues involved with rebasing branches that are already public. - -We use it in practice during an example of splitting your history into two separate repositories in <<ch07-git-tools#_replace>>, using the `--onto` flag as well. - -We go through running into a merge conflict during rebasing in <<ch07-git-tools#ref_rerere>>. - -We also use it in an interactive scripting mode with the `-i` option in <<ch07-git-tools#_changing_multiple>>. - -==== git revert - -The `git revert` command is essentially a reverse `git cherry-pick`. -It creates a new commit that applies the exact opposite of the change introduced in the commit you're targeting, essentially undoing or reverting it. - -We use this in <<ch07-git-tools#_reverse_commit>> to undo a merge commit. - -=== Email - -Many Git projects, including Git itself, are entirely maintained over mailing lists. -Git has a number of tools built into it that help make this process easier, from generating patches you can easily email to applying those patches from an email box. - -==== git apply - -The `git apply` command applies a patch created with the `git diff` or even GNU diff command. -It is similar to what the `patch` command might do with a few small differences. - -We demonstrate using it and the circumstances in which you might do so in <<ch05-distributed-git#_patches_from_email>>. - -==== git am - -The `git am` command is used to apply patches from an email inbox, specifically one that is mbox formatted. -This is useful for receiving patches over email and applying them to your project easily. - -We covered usage and workflow around `git am` in <<ch05-distributed-git#_git_am>> including using the `--resolved`, `-i` and `-3` options. - -There are also a number of hooks you can use to help with the workflow around `git am` and they are all covered in <<ch08-customizing-git#_email_hooks>>. - -We also use it to apply patch formatted GitHub Pull Request changes in <<ch06-github#_email_notifications>>. - -==== git format-patch - -The `git format-patch` command is used to generate a series of patches in mbox format that you can use to send to a mailing list properly formatted. - -We go through an example of contributing to a project using the `git format-patch` tool in <<ch05-distributed-git#_project_over_email>>. - -==== git imap-send - -The `git imap-send` command uploads a mailbox generated with `git format-patch` into an IMAP drafts folder. - -We go through an example of contributing to a project by sending patches with the `git imap-send` tool in <<ch05-distributed-git#_project_over_email>>. - -==== git send-email - -The `git send-email` command is used to send patches that are generated with `git format-patch` over email. - -We go through an example of contributing to a project by sending patches with the `git send-email` tool in <<ch05-distributed-git#_project_over_email>>. - -==== git request-pull - -The `git request-pull` command is simply used to generate an example message body to email to someone. -If you have a branch on a public server and want to let someone know how to integrate those changes without sending the patches over email, you can run this command and send the output to the person you want to pull the changes in. - -We demonstrate how to use `git request-pull` to generate a pull message in <<ch05-distributed-git#_public_project>>. - -=== External Systems - -Git comes with a few commands to integrate with other version control systems. - -==== git svn - -The `git svn` command is used to communicate with the Subversion version control system as a client. -This means you can use Git to checkout from and commit to a Subversion server. - -This command is covered in depth in <<ch09-git-and-other-systems#_git_svn>>. - -==== git fast-import - -For other version control systems or importing from nearly any format, you can use `git fast-import` to quickly map the other format to something Git can easily record. - -This command is covered in depth in <<ch09-git-and-other-systems#_custom_importer>>. - -=== Administration - -If you're administering a Git repository or need to fix something in a big way, Git provides a number of administrative commands to help you out. - -==== git gc - -The `git gc` command runs "`garbage collection`" on your repository, removing unnecessary files in your database and packing up the remaining files into a more efficient format. - -This command normally runs in the background for you, though you can manually run it if you wish. -We go over some examples of this in <<ch10-git-internals#_git_gc>>. - -==== git fsck - -The `git fsck` command is used to check the internal database for problems or inconsistencies. - -We only quickly use this once in <<ch10-git-internals#_data_recovery>> to search for dangling objects. - -==== git reflog - -The `git reflog` command goes through a log of where all the heads of your branches have been as you work to find commits you may have lost through rewriting histories. - -We cover this command mainly in <<ch07-git-tools#_git_reflog>>, where we show normal usage to and how to use `git log -g` to view the same information with `git log` output. - -We also go through a practical example of recovering such a lost branch in <<ch10-git-internals#_data_recovery>>. - -==== git filter-branch - -The `git filter-branch` command is used to rewrite loads of commits according to certain patterns, like removing a file everywhere or filtering the entire repository down to a single subdirectory for extracting a project. - -In <<ch07-git-tools#_removing_file_every_commit>> we explain the command and explore several different options such as `--commit-filter`, `--subdirectory-filter` and `--tree-filter`. - -In <<ch09-git-and-other-systems#_git_p4>> we use it to fix up imported external repositories. - -=== Plumbing Commands - -There were also quite a number of lower level plumbing commands that we encountered in the book. - -The first one we encounter is `ls-remote` in <<ch06-github#_pr_refs>> which we use to look at the raw references on the server. - -We use `ls-files` in <<ch07-git-tools#_manual_remerge>>, <<ch07-git-tools#ref_rerere>> and <<ch07-git-tools#_the_index>> to take a more raw look at what your staging area looks like. - -We also mention `rev-parse` in <<ch07-git-tools#_branch_references>> to take just about any string and turn it into an object SHA-1. - -However, most of the low level plumbing commands we cover are in <<ch10-git-internals#ch10-git-internals>>, which is more or less what the chapter is focused on. -We tried to avoid use of them throughout most of the rest of the book. +* **`git reset`**: Moves data between the Last Snapshot, the Staging Area, and your Sandbox. Essential for undoing complex mistakes (Chapter 7). +* **`git rm`**: Stops tracking a file. Use `--cached` to keep it on your computer but remove it from Git (Chapter 2). +* **`git clean`**: Deletes "junk" and untracked export files from your workspace (Chapter 7). +* **`git gc`**: Performs "garbage collection" to keep the repository fast and efficient (Chapter 10). diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 000000000..8dc468c2c --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,71 @@ +# Pro Git (2nd Edition) - Gemini Context + +This repository contains the source code and assets for the second edition of the **Pro Git** book, written by Scott Chacon and Ben Straub. The book is an open-source guide to mastering Git, available online at [git-scm.com/book](https://git-scm.com/book). + +## Project Overview + +* **Primary Format:** The book is written using **AsciiDoc**. +* **Build System:** Uses **Ruby** with **Asciidoctor** and **Rake**. +* **Architecture:** + * `progit.asc`: The master entry point that includes all chapters and front matter. + * `book/`: Contains the modular content. Each chapter is often represented by a container `.asc` file at the root or in `book/`, which then includes specific section files located in `book/<chapter>/sections/`. + * `images/`: Stores all visual assets (PNG and SVG). + * `theme/`: Contains styling and templates for various output formats (HTML, PDF, EPUB, Mobi). + * `diagram-source/`: Holds the original **Sketch 3** (`.sketch`) files for diagrams. + +## Building and Running + +The project uses `rake` to orchestrate the build process. Ensure you have Ruby installed and run `bundle install` first. + +### Key Build Commands + +* **Build all formats:** + ```bash + bundle exec rake book:build + ``` +* **Build HTML:** + ```bash + bundle exec rake book:build_html + ``` +* **Build PDF:** + ```bash + bundle exec rake book:build_pdf + ``` +* **Build EPUB:** + ```bash + bundle exec rake book:build_epub + ``` +* **Build Mobi:** + ```bash + bundle exec rake book:build_mobi + ``` +* **Clean generated files:** + ```bash + bundle exec rake book:clean + ``` + +## Development Conventions + +### Content Authoring +* **AsciiDoc:** Adhere to AsciiDoc syntax. Refer to the [AsciiDoc Quick Reference](https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/) if needed. +* **Modular Sections:** Do not write large blocks of text directly in the chapter container files. Instead, create section files in the appropriate `book/<chapter>/sections/` directory and include them in the main chapter file. +* **Cross-references:** Use the `[[anchor]]` syntax for defining anchors and `<<anchor>>` or `xref:anchor[]` for referencing them. + +### Images and Diagrams +* **Source Files:** Original diagrams are in `diagram-source/progit.sketch`. Use Sketch 3 to modify them. +* **Exporting:** Slices in Sketch should match the target filename and be exported at `800w`. +* **Referencing:** Use the `image::images/filename.png[]` macro in AsciiDoc. + +### Contributions +* **Licensing:** All contributions are provided under the Creative Commons license specified in `LICENSE.asc`. +* **Translation:** Translations are maintained in separate repositories. Refer to `TRANSLATING.md` for more information. +* **Issues:** Check for existing issues before reporting new ones. Verify if the issue persists in the PDF version or the source files, as the website might lag behind. + +## Key Files Summary + +* `progit.asc`: The main book file. +* `Rakefile`: Defines all build tasks. +* `Gemfile`: Lists Ruby dependencies (Asciidoctor, etc.). +* `atlas.json`: Configuration for the O'Reilly Atlas publishing platform. +* `status.json`: Metadata about chapters and their translation/completion status. +* `CONTRIBUTING.md`: Detailed guidelines for contributors. diff --git a/book/01-introduction/sections/about-version-control.asc b/book/01-introduction/sections/about-version-control.asc index 182fcedc0..f99b94b27 100644 --- a/book/01-introduction/sections/about-version-control.asc +++ b/book/01-introduction/sections/about-version-control.asc @@ -1,61 +1,63 @@ === About Version Control +tag::concept[] (((version control))) -What is "`version control`", and why should you care? -Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. -For the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer. +What is "`version control`", and why should you care? -If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. -It allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. -Using a VCS also generally means that if you screw things up or lose files, you can easily recover. -In addition, you get all this for very little overhead. +Imagine Nora, a UX Lead at a small startup called SketchSpark. Before this role, Nora worked at a high-pressure design agency where she managed research for dozens of clients. Her primary "version control" system was a shared drive filled with files named `research-findings_final_v3_REAL_USE-THIS.pdf`. + +One Tuesday morning, her cloud sync glitched and overwritten her folder with a week-old version. Three weeks of interview notes, a revised competitive analysis, and a journey map she'd spent days refining were simply... gone. She spent forty-eight hours reconstructing what she could from memory and old Slack messages, but the competitive analysis was lost forever. + +This is the moment Nora realized she needed something better than a shared drive and clever filenames. She needed a professional "time machine." + +Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. While developers use it for software source code, for Nora, it's about tracking **design decisions**, research iterations, and visual assets. + +If you are a UI or UX designer, you already practice a primitive form of version control every time you save a new version of a layout or duplicate a Figma page "just in case." A Version Control System (VCS) replaces this manual anxiety with a structured workflow. It allows you to: + +* Revert a project brief back to its state before a confusing edit. +* Compare two different layout explorations side-by-side to see which one evolved more effectively. +* Identify exactly when a specific design token was changed—and who changed it. +* Recover deleted assets without begging IT for a backup. + +Using a VCS also generally means that if you screw things up or lose files, you can easily recover. In addition, you get all this for very little overhead. ==== Local Version Control Systems +tag::concept[] (((version control,local))) -Many people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever). -This approach is very common because it is so simple, but it is also incredibly error prone. -It is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to. +Many people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever). This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to. To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control. -.Local version control diagram +.Local version control for design projects image::images/local.png[Local version control diagram] -One of the most popular VCS tools was a system called RCS, which is still distributed with many computers today. -https://www.gnu.org/software/rcs/[RCS^] works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches. +One of the most popular VCS tools was a system called RCS, which is still distributed with many computers today. RCS works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches. While this is fast and efficient for text, Nora will soon learn that Git treats her high-resolution journey map PNGs and Sketch files differently. ==== Centralized Version Control Systems +tag::concept[] (((version control,centralized))) -The next major issue that people encounter is that they need to collaborate with developers on other systems. -To deal with this problem, Centralized Version Control Systems (CVCSs) were developed. -These systems (such as CVS, Subversion, and Perforce) have a single server that contains all the versioned files, and a number of clients that check out files from that central place.(((CVS)))(((Subversion)))(((Perforce))) -For many years, this has been the standard for version control. +As the SketchSpark team grows, Nora needs to collaborate with Sam, a fast-moving UI designer. They need to work on the same project simultaneously. This is where Centralized Version Control Systems (CVCSs) like Subversion or Perforce come in. -.Centralized version control diagram +These systems have a single server that contains all the versioned files, and a number of clients that check out files from that central place. + +.Centralized version control: Nora and Sam connect to one source image::images/centralized.png[Centralized version control diagram] -This setup offers many advantages, especially over local VCSs. -For example, everyone knows to a certain degree what everyone else on the project is doing. -Administrators have fine-grained control over who can do what, and it's far easier to administer a CVCS than it is to deal with local databases on every client. +This offers many advantages. Nora knows what Sam is working on, and Sam can access Nora's latest user flows. Administrators have fine-grained control over who can do what, and it’s far easier to administer a CVCS than it is to deal with local databases on every client. -However, this setup also has some serious downsides. -The most obvious is the single point of failure that the centralized server represents. -If that server goes down for an hour, then during that hour nobody can collaborate at all or save versioned changes to anything they're working on. -If the hard disk the central database is on becomes corrupted, and proper backups haven't been kept, you lose absolutely everything -- the entire history of the project except whatever single snapshots people happen to have on their local machines. -Local VCSs suffer from this same problem -- whenever you have the entire history of the project in a single place, you risk losing everything. +However, this setup has a major downside: the single point of failure. If the server goes down for an hour, nobody can save their work or collaborate. If the server’s hard drive becomes corrupted and backups haven't been kept, Nora loses absolutely everything—the entire history of the SketchSpark project except for whatever single snapshots happen to be on her or Sam's local machines. ==== Distributed Version Control Systems +tag::concept[] (((version control,distributed))) -This is where Distributed Version Control Systems (DVCSs) step in. -In a DVCS (such as Git, Mercurial or Darcs), clients don't just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history. -Thus, if any server dies, and these systems were collaborating via that server, any of the client repositories can be copied back up to the server to restore it. -Every clone is really a full backup of all the data. +This is where Distributed Version Control Systems (DVCSs) step in. In a DVCS (such as Git), clients don’t just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history. -.Distributed version control diagram +.Distributed version control: Every team member has a full backup image::images/distributed.png[Distributed version control diagram] -Furthermore, many of these systems deal pretty well with having several remote repositories they can work with, so you can collaborate with different groups of people in different ways simultaneously within the same project. -This allows you to set up several types of workflows that aren't possible in centralized systems, such as hierarchical models. +Thus, if the server dies, any of the client repositories—Nora’s, Sam’s, or the illustrator Priya’s—can be copied back up to the server to restore it. Every clone is really a full backup of all the data. + +Furthermore, many of these systems deal exceptionally well with having several remote repositories they can work with. This allows Nora and Sam to set up "parallel explorations" that aren't possible in centralized systems. Sam can branch off to try a new card layout while Nora continues refining the user flows on the main branch, and they can merge those two "truths" together later. diff --git a/book/01-introduction/sections/command-line.asc b/book/01-introduction/sections/command-line.asc index e7fd185bb..1eb805cfc 100644 --- a/book/01-introduction/sections/command-line.asc +++ b/book/01-introduction/sections/command-line.asc @@ -1,11 +1,11 @@ === The Command Line +tag::concept[] -There are a lot of different ways to use Git. -There are the original command-line tools, and there are many graphical user interfaces of varying capabilities. -For this book, we will be using Git on the command line. -For one, the command line is the only place you can run _all_ Git commands -- most of the GUIs implement only a partial subset of Git functionality for simplicity. -If you know how to run the command-line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true. -Also, while your choice of graphical client is a matter of personal taste, _all_ users will have the command-line tools installed and available. +(((command line))) +There are a lot of different ways to use Git. There are the original command-line tools, and there are many graphical user interfaces (GUIs) of varying capabilities. For this book, we will be using Git on the command line. -So we will expect you to know how to open Terminal in macOS or Command Prompt or PowerShell in Windows. -If you don't know what we're talking about here, you may need to stop and research that quickly so that you can follow the rest of the examples and descriptions in this book. +First, the command line is the only place you can run **all** Git commands—most of the GUIs implement only a partial subset of Git functionality for simplicity. If you know how to run the command-line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true. + +Second, for a "power designer" like Nora, the command line is fast. Once you get past the initial learning curve, typing a few characters is often quicker than navigating through nested menus. Also, while your choice of graphical client is a matter of personal taste, **all** users will have the command-line tools installed and available. + +While we will show you how to use various GUIs (like GitHub Desktop or VS Code) in the Appendices, the core of this book will focus on the terminal. Don't worry if you've never used one before; we'll guide you through every command step-by-step. diff --git a/book/01-introduction/sections/first-time-setup.asc b/book/01-introduction/sections/first-time-setup.asc index 10b7049ce..ed8e1cb96 100644 --- a/book/01-introduction/sections/first-time-setup.asc +++ b/book/01-introduction/sections/first-time-setup.asc @@ -1,95 +1,55 @@ [[_first_time]] === First-Time Git Setup +tag::procedure[] -Now that you have Git on your system, you'll want to do a few things to customize your Git environment. -You should have to do these things only once on any given computer; they'll stick around between upgrades. -You can also change them at any time by running through the commands again. +(((setup))) +Now that you have Git on your system, you'll want to do a few things to customize your Git environment. You should have to do these things only once on any given computer; they'll stick around between upgrades. You can also change them at any time by running through the commands again. -Git comes with a tool called `git config` that lets you get and set configuration variables that control all aspects of how Git looks and operates.(((git commands, config))) -These variables can be stored in three different places: +Git comes with a tool called `git config` that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places: -1. `[path]/etc/gitconfig` file: Contains values applied to every user on the system and all their repositories. - If you pass the option `--system` to `git config`, it reads and writes from this file specifically. - Because this is a system configuration file, you would need administrative or superuser privilege to make changes to it. -2. `~/.gitconfig` or `~/.config/git/config` file: Values specific personally to you, the user. - You can make Git read and write to this file specifically by passing the `--global` option, and this affects _all_ of the repositories you work with on your system. -3. `config` file in the Git directory (that is, `.git/config`) of whatever repository you're currently using: Specific to that single repository. - You can force Git to read from and write to this file with the `--local` option, but that is in fact the default. - Unsurprisingly, you need to be located somewhere in a Git repository for this option to work properly. +1. **System-level** (`/etc/gitconfig`): Values applied to every user on the system. Pass `--system` to `git config` to access this. +2. **User-level** (`~/.gitconfig`): Values specific personally to you. Pass `--global` to access this. This affects **all** of your repositories. +3. **Local-level** (`.git/config`): Specific to that single repository. This is the default. -Each level overrides values in the previous level, so values in `.git/config` trump those in `[path]/etc/gitconfig`. - -On Windows systems, Git looks for the `.gitconfig` file in the `$HOME` directory (`C:\Users\$USER` for most people). -It also still looks for `[path]/etc/gitconfig`, although it's relative to the MSys root, which is wherever you decide to install Git on your Windows system when you run the installer. -If you are using version 2.x or later of Git for Windows, there is also a system-level config file at `C:\Documents and Settings\All Users\Application Data\Git\config` on Windows XP, and in `C:\ProgramData\Git\config` on Windows Vista and newer. -This config file can only be changed by `git config -f <file>` as an admin. - -You can view all of your settings and where they are coming from using: - -[source,console] ----- -$ git config --list --show-origin ----- +Each level overrides values in the previous level. On Windows, Git looks for the `.gitconfig` file in the `$HOME` directory (`C:\Users\$USER` for most people). ==== Your Identity +tag::procedure[] + +The first thing you should do when you install Git is to set your user name and email address. This is important because every Git commit uses this information, and it's immutably baked into the commits you start creating. -The first thing you should do when you install Git is to set your user name and email address. -This is important because every Git commit uses this information, and it's immutably baked into the commits you start creating: +For Nora at SketchSpark, she wants to make sure her name is attached to all the research checkpoints she's about to create. She opens her terminal and types: [source,console] ---- -$ git config --global user.name "John Doe" -$ git config --global user.email johndoe@example.com +$ git config --global user.name "Nora UX" +$ git config --global user.email nora@sketchspark.io ---- -Again, you need to do this only once if you pass the `--global` option, because then Git will always use that information for your user on that system. -If you want to override this with a different name or email address for specific projects, you can run the command without the `--global` option when you're in that project. +Again, you need to do this only once if you pass the `--global` option, because then Git will always use that information for anything you do on that system. -Many of the GUI tools will help you do this when you first run them. - -[[_editor]] ==== Your Editor +tag::procedure[] -Now that your identity is set up, you can configure the default text editor that will be used when Git needs you to type in a message. -If not configured, Git uses your system's default editor. - -If you want to use a different text editor, such as Emacs, you can do the following: - -[source,console] ----- -$ git config --global core.editor emacs ----- - -On a Windows system, if you want to use a different text editor, you must specify the full path to its executable file. -This can be different depending on how your editor is packaged. +(((editor))) +Now that your identity is set up, you can configure the default text editor that will be used when Git needs you to type in a message. If not configured, Git uses your system’s default editor. -In the case of Notepad++, a popular programming editor, you are likely to want to use the 32-bit version, since at the time of writing the 64-bit version doesn't support all plug-ins. -If you are on a 32-bit Windows system, or you have a 64-bit editor on a 64-bit system, you'll type something like this: +If you want to use a different text editor, such as VS Code (which Sam uses), you can configure it like this: [source,console] ---- -$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" +$ git config --global core.editor "code --wait" ---- [NOTE] ==== -Vim, Emacs and Notepad++ are popular text editors often used by developers on Unix-based systems like Linux and macOS or a Windows system. -If you are using another editor, or a 32-bit version, please find specific instructions for how to set up your favorite editor with Git in <<C-git-commands#ch_core_editor>>. +If you are using another editor, please find specific instructions for how to set up your favorite editor with Git in <<C-git-commands#ch_core_editor>>. ==== -[WARNING] -==== -You may find, if you don't setup your editor like this, you get into a really confusing state when Git attempts to launch it. -An example on a Windows system may include a prematurely terminated Git operation during a Git initiated edit. -==== - -[[_new_default_branch]] -==== Your default branch name - -By default Git will create a branch called _master_ when you create a new repository with `git init`. -From Git version 2.28 onwards, you can set a different name for the initial branch. +==== Your Default Branch Name +tag::procedure[] -To set _main_ as the default branch name do: +By default, Git will create a branch called *master* when you create a new repository with `git init`. From Git version 2.28 onwards, you can set a different name for the initial branch. Nora prefers the modern convention: [source,console] ---- @@ -97,40 +57,22 @@ $ git config --global init.defaultBranch main ---- ==== Checking Your Settings +tag::procedure[] If you want to check your configuration settings, you can use the `git config --list` command to list all the settings Git can find at that point: [source,console] ---- $ git config --list -user.name=John Doe -user.email=johndoe@example.com -color.status=auto -color.branch=auto -color.interactive=auto -color.diff=auto +user.name=Nora UX +user.email=nora@sketchspark.io ... ---- -You may see keys more than once, because Git reads the same key from different files (`[path]/etc/gitconfig` and `~/.gitconfig`, for example). -In this case, Git uses the last value for each unique key it sees. - -You can also check what Git thinks a specific key's value is by typing `git config <key>`:(((git commands, config))) +You may see keys more than once, because Git reads the same key from different files. In this case, Git uses the last value for each unique key it sees. You can also check what Git thinks a specific key’s value is by typing `git config <key>`: [source,console] ---- $ git config user.name -John Doe +Nora UX ---- - -[NOTE] -==== -Since Git might read the same configuration variable value from more than one file, it's possible that you have an unexpected value for one of these values and you don't know why. -In cases like that, you can query Git as to the _origin_ for that value, and it will tell you which configuration file had the final say in setting that value: - -[source,console] ----- -$ git config --show-origin rerere.autoUpdate -file:/home/johndoe/.gitconfig false ----- -==== diff --git a/book/01-introduction/sections/help.asc b/book/01-introduction/sections/help.asc index 68d76a4cf..3069cc378 100644 --- a/book/01-introduction/sections/help.asc +++ b/book/01-introduction/sections/help.asc @@ -1,6 +1,8 @@ [[_git_help]] === Getting Help +tag::reference[] +(((help))) If you ever need help while using Git, there are three equivalent ways to get the comprehensive manual page (manpage) help for any of the Git commands: [source,console] @@ -10,41 +12,18 @@ $ git <verb> --help $ man git-<verb> ---- -For example, you can get the manpage help for the `git config` command by running this:(((git commands, help))) +For example, you can get the manpage help for the `git config` command by running this: [source,console] ---- $ git help config ---- -These commands are nice because you can access them anywhere, even offline. -If the manpages and this book aren't enough and you need in-person help, you can try the `#git`, `#github`, or `#gitlab` channels on the Libera Chat IRC server, which can be found at https://libera.chat/[^]. -These channels are regularly filled with hundreds of people who are all very knowledgeable about Git and are often willing to help.(((IRC))) +These commands are nice because you can access them anywhere, even offline. If the manpages and this book aren't enough and you need in-person help, you can try the `#git` or `#github` channels on the Libera Chat IRC server (https://libera.chat/[^]). -In addition, if you don't need the full-blown manpage help, but just need a quick refresher on the available options for a Git command, you can ask for the more concise "`help`" output with the `-h` option, as in: +In addition, if you just need a quick refresher on the available options for a Git command, you can ask for the more concise "help" output with the `-h` option, as in: [source,console] ---- $ git add -h -usage: git add [<options>] [--] <pathspec>... - - -n, --dry-run dry run - -v, --verbose be verbose - - -i, --interactive interactive picking - -p, --patch select hunks interactively - -e, --edit edit current diff and apply - -f, --force allow adding otherwise ignored files - -u, --update update tracked files - --renormalize renormalize EOL of tracked files (implies -u) - -N, --intent-to-add record only the fact that the path will be added later - -A, --all add changes from all tracked and untracked files - --ignore-removal ignore paths removed in the working tree (same as --no-all) - --refresh don't add, only refresh the index - --ignore-errors just skip files which cannot be added because of errors - --ignore-missing check if - even missing - files are ignored in dry run - --sparse allow updating entries outside of the sparse-checkout cone - --chmod (+|-)x override the executable bit of the listed files - --pathspec-from-file <file> read pathspec from file - --pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character ---- diff --git a/book/01-introduction/sections/history.asc b/book/01-introduction/sections/history.asc index 7ab05fd3b..e1581e1e4 100644 --- a/book/01-introduction/sections/history.asc +++ b/book/01-introduction/sections/history.asc @@ -1,20 +1,15 @@ === A Short History of Git +tag::history[] -As with many great things in life, Git began with a bit of creative destruction and fiery controversy. +(((history))) +In the land of software development, Git's origin story is legendary. It was born out of crisis and "creative destruction." The Linux kernel project—a massive, open-source effort—used a proprietary version control system called BitKeeper. In 2005, the relationship between the Linux community and BitKeeper broke down, and the tool's free-of-charge status was revoked. -The Linux kernel is an open source software project of fairly large scope.(((Linux))) -During the early years of the Linux kernel maintenance (1991–2002), changes to the software were passed around as patches and archived files. -In 2002, the Linux kernel project began using a proprietary DVCS called BitKeeper.(((BitKeeper))) +This prompted Linus Torvalds, the creator of Linux, to develop his own tool based on some of the lessons they learned while using BitKeeper. Some of the goals of the new system were as follows: -In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool's free-of-charge status was revoked. -This prompted the Linux development community (and in particular Linus Torvalds, the creator of Linux) to develop their own tool based on some of the lessons they learned while using BitKeeper.(((Linus Torvalds))) -Some of the goals of the new system were as follows: +* Speed +* Simple design +* Strong support for non-linear development (thousands of parallel branches) +* Fully distributed +* Able to handle large projects like the Linux kernel efficiently (speed and data size) -* Speed -* Simple design -* Strong support for non-linear development (thousands of parallel branches) -* Fully distributed -* Able to handle large projects like the Linux kernel efficiently (speed and data size) - -Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities. -It's amazingly fast, it's very efficient with large projects, and it has an incredible branching system for non-linear development (see <<ch03-git-branching#ch03-git-branching>>). +Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities. For Nora and her design team at SketchSpark, this history matters because it explains why Git is so robust. It wasn't built for simple file sharing; it was built to manage high-stakes, parallel collaboration on a global scale. Today, those same features—speed, data integrity, and an incredible branching system—are exactly what make Git the perfect "source of truth" for complex design systems. diff --git a/book/01-introduction/sections/installing.asc b/book/01-introduction/sections/installing.asc index d4f6dcbd1..89e1db164 100644 --- a/book/01-introduction/sections/installing.asc +++ b/book/01-introduction/sections/installing.asc @@ -1,42 +1,19 @@ === Installing Git +tag::procedure[] -Before you start using Git, you have to make it available on your computer. -Even if it's already installed, it's probably a good idea to update to the latest version. -You can either install it as a package or via another installer, or download the source code and compile it yourself. +(((installing))) +Before you start using Git for your design projects, you have to make it available on your computer. Even if it's already installed, it's probably a good idea to update to the latest version. You can either install it as a package or via another installer, or download the source code and compile it yourself. [NOTE] ==== -This book was written using Git version 2. -Since Git is quite excellent at preserving backwards compatibility, any recent version should work just fine. -Though most of the commands we use should work even in ancient versions of Git, some of them might not or might act slightly differently. +This book was written using Git version 2. Since Git is quite excellent at preserving backwards compatibility, any recent version should work just fine. ==== -==== Installing on Linux - -(((Linux, installing))) -If you want to install the basic Git tools on Linux via a binary installer, you can generally do so through the package management tool that comes with your distribution. -If you're on Fedora (or any closely-related RPM-based distribution, such as RHEL or CentOS), you can use `dnf`: - -[source,console] ----- -$ sudo dnf install git-all ----- - -If you're on a Debian-based distribution, such as Ubuntu, try `apt`: - -[source,console] ----- -$ sudo apt install git-all ----- - -For more options, there are instructions for installing on several different Unix distributions on the Git website, at https://git-scm.com/download/linux[^]. - ==== Installing on macOS +tag::procedure[] (((macOS, installing))) -There are several ways to install Git on macOS. -The easiest is probably to install the Xcode Command Line Tools.(((Xcode))) -On Mavericks (10.9) or above you can do this simply by trying to run `git` from the Terminal the very first time. +There are several ways to install Git on macOS. The easiest is probably to install the Xcode Command Line Tools. On Mavericks (10.9) or above you can do this simply by trying to run `git` from the Terminal the very first time. [source,console] ---- @@ -45,93 +22,35 @@ $ git --version If you don't have it installed already, it will prompt you to install it. -If you want a more up to date version, you can also install it via a binary installer. -A macOS Git installer is maintained and available for download at the Git website, at https://git-scm.com/download/mac[^]. +If you want a more up-to-date version, you can also install it via a binary installer. A macOS Git installer is maintained and available for download at the Git website, at https://git-scm.com/download/mac[^]. .Git macOS installer image::images/git-osx-installer.png[Git macOS installer] ==== Installing on Windows +tag::procedure[] There are also a few ways to install Git on Windows.(((Windows, installing))) -The most official build is available for download on the Git website. -Just go to https://git-scm.com/download/win[^] and the download will start automatically. -Note that this is a project called Git for Windows, which is separate from Git itself; for more information on it, go to https://gitforwindows.org[^]. - -To get an automated installation you can use the https://community.chocolatey.org/packages/git[Git Chocolatey package^]. -Note that the Chocolatey package is community maintained. - -==== Installing from Source - -Some people may instead find it useful to install Git from source, because you'll get the most recent version. -The binary installers tend to be a bit behind, though as Git has matured in recent years, this has made less of a difference. +The most official build is available for download on the Git website. Just go to https://git-scm.com/download/win[^] and the download will start automatically. Note that this is a project called Git for Windows, which is separate from Git itself; for more information on it, go to https://gitforwindows.org[^]. -If you do want to install Git from source, you need to have the following libraries that Git depends on: autotools, curl, zlib, openssl, expat, and libiconv. -For example, if you're on a system that has `dnf` (such as Fedora) or `apt-get` (such as a Debian-based system), you can use one of these commands to install the minimal dependencies for compiling and installing the Git binaries: +To get an automated installation you can use the https://community.chocolatey.org/packages/git[Git Chocolatey package^]. Note that the Chocolatey package is community maintained. -[source,console] ----- -$ sudo dnf install dh-autoreconf curl-devel expat-devel gettext-devel \ - openssl-devel perl-devel zlib-devel -$ sudo apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev \ - gettext libz-dev libssl-dev ----- - -In order to be able to add the documentation in various formats (doc, html, info), these additional dependencies are required: - -[source,console] ----- -$ sudo dnf install asciidoc xmlto docbook2X -$ sudo apt-get install asciidoc xmlto docbook2x ----- - -[NOTE] -==== -Users of RHEL and RHEL-derivatives like CentOS and Scientific Linux will have to https://docs.fedoraproject.org/en-US/epel/#how_can_i_use_these_extra_packages[enable the EPEL repository^] to download the `docbook2X` package. -==== - -If you're using a Debian-based distribution (Debian/Ubuntu/Ubuntu-derivatives), you also need the `install-info` package: - -[source,console] ----- -$ sudo apt-get install install-info ----- - -If you're using a RPM-based distribution (Fedora/RHEL/RHEL-derivatives), you also need the `getopt` package (which is already installed on a Debian-based distro): - -[source,console] ----- -$ sudo dnf install getopt ----- +==== Installing on Linux +tag::procedure[] -Additionally, if you're using Fedora/RHEL/RHEL-derivatives, you need to do this: +(((Linux, installing))) +If you want to install the basic Git tools on Linux via a binary installer, you can generally do so through the package management tool that comes with your distribution. If you're on Fedora (or any RPM-based distribution), you can use `dnf`: [source,console] ---- -$ sudo ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi +$ sudo dnf install git-all ---- -due to binary name differences. - -When you have all the necessary dependencies, you can go ahead and grab the latest tagged release tarball from several places. -You can get it via the kernel.org site, at https://www.kernel.org/pub/software/scm/git[^], or the mirror on the GitHub website, at https://github.com/git/git/tags[^]. -It's generally a little clearer what the latest version is on the GitHub page, but the kernel.org page also has release signatures if you want to verify your download. - -Then, compile and install: +If you're on a Debian-based distribution, such as Ubuntu, try `apt`: [source,console] ---- -$ tar -zxf git-2.8.0.tar.gz -$ cd git-2.8.0 -$ make configure -$ ./configure --prefix=/usr -$ make all doc info -$ sudo make install install-doc install-html install-info +$ sudo apt install git-all ---- -After this is done, you can also get Git via Git itself for updates: - -[source,console] ----- -$ git clone https://git.kernel.org/pub/scm/git/git.git ----- +For more options, there are instructions for installing on several different Unix distributions on the Git website, at https://git-scm.com/download/linux[^]. diff --git a/book/01-introduction/sections/what-is-git.asc b/book/01-introduction/sections/what-is-git.asc index 466201b23..7ff34da16 100644 --- a/book/01-introduction/sections/what-is-git.asc +++ b/book/01-introduction/sections/what-is-git.asc @@ -1,109 +1,69 @@ [[what_is_git_section]] === What is Git? +tag::concept[] -So, what is Git in a nutshell? -This is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you. -As you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid subtle confusion when using the tool. -Even though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in a very different way, and understanding these differences will help you avoid becoming confused while using it.(((Subversion)))(((Perforce))) +(((what is Git))) +If you've used other version control systems (like Subversion), you might need to "unlearn" some concepts. Git thinks about data differently. Even though Git's user interface is fairly similar to other systems, Git stores and thinks about information in a very different way. Understanding these differences will help you avoid becoming confused while using it. ==== Snapshots, Not Differences +tag::concept[] -The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data. -Conceptually, most other systems store information as a list of file-based changes. -These other systems (CVS, Subversion, Perforce, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as _delta-based_ version control). +(((snapshots))) +The major difference between Git and any other VCS is the way Git thinks about its data. Imagine Nora is working on the SketchSpark landing page. In many other systems, the system stores the initial file and then a list of "deltas" (what changed) for every save. -.Storing data as changes to a base version of each file -image::images/deltas.png[Storing data as changes to a base version of each file] +.Other systems store data as changes to a base version +image::images/deltas.png[Deltas diagram] -Git doesn't think of or store its data this way. -Instead, Git thinks of its data more like a series of snapshots of a miniature filesystem. -With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. -To be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already stored. -Git thinks about its data more like a *stream of snapshots*. +Git doesn't think of or store its data this way. Instead, Git thinks of its data more like a series of **snapshots** of a miniature filesystem. Every time Nora creates a "checkpoint" (a commit), Git basically takes a picture of what all her files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already stored. -.Storing data as snapshots of the project over time -image::images/snapshots.png[Git stores data as snapshots of the project over time] +.Git stores data as snapshots of the project over time +image::images/snapshots.png[Snapshots diagram] -This is an important distinction between Git and nearly all other VCSs. -It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation. -This makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS. -We'll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in <<ch03-git-branching#ch03-git-branching>>. +This is a critical mental shift. It makes Git more like a mini filesystem with incredibly powerful tools built on top of it, rather than simply a VCS. For a designer, a commit isn't just a list of "edits"; it is a **version of the truth**. ==== Nearly Every Operation Is Local +tag::concept[] -Most operations in Git need only local files and resources to operate -- generally no information is needed from another computer on your network. -If you're used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers. -Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous. +Most operations in Git need only local files and resources to operate—generally no information is needed from another computer on your network. If Nora is on a plane with no Wi-Fi, she can still browse the project's history, compare her current layout to a version from last week, and create new checkpoints. -For example, to browse the history of the project, Git doesn't need to go out to the server to get the history and display it for you -- it simply reads it directly from your local database. -This means you see the project history almost instantly. -If you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally. - -This also means that there is very little you can't do if you're offline or off VPN. -If you get on an airplane or a train and want to do a little work, you can commit happily (to your _local_ copy, remember?) until you get to a network connection to upload. -If you go home and can't get your VPN client working properly, you can still work. -In many other systems, doing so is either impossible or painful. -In Perforce, for example, you can't do much when you aren't connected to the server; in Subversion and CVS, you can edit files, but you can't commit changes to your database (because your database is offline). -This may not seem like a huge deal, but you may be surprised what a big difference it can make. +Because she has the entire history of the SketchSpark project on her local disk, most operations seem almost instantaneous. She doesn't have to wait for a server to respond just to see who last updated the design tokens. This also means she can work offline and "upload" her checkpoints once she reaches a network connection. ==== Git Has Integrity +tag::concept[] -Everything in Git is checksummed before it is stored and is then referred to by that checksum. -This means it's impossible to change the contents of any file or directory without Git knowing about it. -This functionality is built into Git at the lowest levels and is integral to its philosophy. -You can't lose information in transit or get file corruption without Git being able to detect it. +Everything in Git is checksummed before it is stored and is then referred to by that checksum. This means it's impossible to change the contents of any file or directory without Git knowing about it. This functionality is built into Git at the lowest levels and is integral to its philosophy. You can't lose information in transit or get file corruption without Git being able to detect it. -The mechanism that Git uses for this checksumming is called a SHA-1 hash.(((SHA-1))) -This is a 40-character string composed of hexadecimal characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git. -A SHA-1 hash looks something like this: +The mechanism that Git uses for this checksumming is called a SHA-1 hash. It's a 40-character string that looks like this: -[source] ----- -24b9da6552252987aa493b52f8696cd6d3b00373 ----- +`24b9da6552252987aa493b52f8696cd6d3b00373` -You will see these hash values all over the place in Git because it uses them so much. -In fact, Git stores everything in its database not by file name but by the hash value of its contents. +You will see these hash values all over the place in Git because it uses them so much. In fact, Git stores everything in its database not by file name but by the hash value of its contents. ==== Git Generally Only Adds Data +tag::concept[] -When you do actions in Git, nearly all of them only _add_ data to the Git database. -It is hard to get the system to do anything that is not undoable or to make it erase data in any way. -As with any VCS, you can lose or mess up changes you haven't committed yet, but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository. - -This makes using Git a joy because we know we can experiment without the danger of severely screwing things up. -For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see <<ch02-git-basics-chapter#_undoing>>. +When you do actions in Git, nearly all of them only **add** data to the Git database. It is hard to get the system to do anything that is not undoable or to make it erase data in any way. This is Nora's safety net. Once she commits a snapshot into Git, it is very difficult to lose, especially if she regularly pushes her database to another repository. This makes using Git a joy because designers can experiment without the danger of severely screwing things up. ==== The Three States +tag::concept[] -Pay attention now -- here is the main thing to remember about Git if you want the rest of your learning process to go smoothly. -Git has three main states that your files can reside in: _modified_, _staged_, and _committed_: +(((three states))) +Pay attention now—here is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: **modified**, **staged**, and **committed**: -* Modified means that you have changed the file but have not committed it to your database yet. -* Staged means that you have marked a modified file in its current version to go into your next commit snapshot. -* Committed means that the data is safely stored in your local database. +* **Modified** means that you have changed the file but have not committed it to your database yet. (Nora has updated the `product-brief.md` but hasn't "saved" it as a checkpoint). +* **Staged** means that you have marked a modified file in its current version to go into your next commit snapshot. (Nora selects the research notes to be included in her next "checkpoint"). +* **Committed** means that the data is safely stored in your local database. This leads us to the three main sections of a Git project: the working tree, the staging area, and the Git directory. .Working tree, staging area, and Git directory image::images/areas.png["Working tree, staging area, and Git directory"] -The working tree is a single checkout of one version of the project. -These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. - -The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. -Its technical name in Git parlance is the "`index`", but the phrase "`staging area`" works just as well. - -The Git directory is where Git stores the metadata and object database for your project. -This is the most important part of Git, and it is what is copied when you _clone_ a repository from another computer. - -The basic Git workflow goes something like this: +1. **Working Tree:** The files you are currently editing on your computer. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. +2. **Staging Area:** A simple file (technically the "index") that stores information about what will go into your next commit. +3. **Git Directory:** Where Git stores the metadata and object database for your project. This is what is copied when you **clone** a repository from another computer. +The basic Git workflow goes like this: 1. You modify files in your working tree. -2. You selectively stage just those changes you want to be part of your next commit, which adds _only_ those changes to the staging area. -3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. - -If a particular version of a file is in the Git directory, it's considered _committed_. -If it has been modified and was added to the staging area, it is _staged_. -And if it was changed since it was checked out but has not been staged, it is _modified_. -In <<ch02-git-basics-chapter#ch02-git-basics-chapter>>, you'll learn more about these states and how you can either take advantage of them or skip the staged part entirely. +2. You selectively **stage** just those changes you want to be part of your next commit. +3. You do a **commit**, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. diff --git a/book/02-git-basics/sections/aliases.asc b/book/02-git-basics/sections/aliases.asc index 5d6d117cd..89f06d97b 100644 --- a/book/02-git-basics/sections/aliases.asc +++ b/book/02-git-basics/sections/aliases.asc @@ -1,70 +1,59 @@ -[[_git_aliases]] === Git Aliases +tag::concept[] (((aliases))) -Before we move on to the next chapter, we want to introduce a feature that can make your Git experience simpler, easier, and more familiar: aliases. -For clarity's sake, we won't be using them anywhere else in this book, but if you go on to use Git with any regularity, aliases are something you should know about. +Before we move on to branching, there’s one feature that can make Nora’s life on the command line much easier: **aliases**. -Git doesn't automatically infer your command if you type it in partially. -If you don't want to type the entire text of each of the Git commands, you can easily set up an alias for each command using `git config`.(((git commands, config))) -Here are a couple of examples you may want to set up: +Git doesn't automatically infer your command if you type it in partially. If you don't want to type the entire text of each Git command, you can set up a shorthand (alias) for each command using `git config`. -[source,console] +==== Basic Shorthands +tag::procedure[] + +Nora sets up a few aliases for the commands she uses most frequently: + +[source,bash] ---- +$ git config --global alias.st status $ git config --global alias.co checkout -$ git config --global alias.br branch $ git config --global alias.ci commit -$ git config --global alias.st status +$ git config --global alias.br branch ---- -This means that, for example, instead of typing `git commit`, you just need to type `git ci`. -As you go on using Git, you'll probably use other commands frequently as well; don't hesitate to create new aliases. +This means that instead of typing `git status`, Nora can now just type `git st`. For a designer who is constantly checking the state of her project, this saves dozens of keystrokes a day. + +==== Creating Custom Commands +tag::procedure[] -This technique can also be very useful in creating commands that you think should exist. -For example, to correct the usability problem you encountered with unstaging a file, you can add your own unstage alias to Git: +Aliases can also be used to create new commands that you think *should* exist. For example, to simplify the process of unstaging a file, Nora adds an `unstage` alias: -[source,console] +[source,bash] ---- -$ git config --global alias.unstage 'reset HEAD --' +$ git config --global alias.unstage 'restore --staged --' ---- -This makes the following two commands equivalent: +Now, these two commands are equivalent: -[source,console] +[source,bash] ---- -$ git unstage fileA -$ git reset HEAD -- fileA +$ git unstage research/personas/early-adopter.md +$ git restore --staged -- research/personas/early-adopter.md ---- -This seems a bit clearer. -It's also common to add a `last` command, like this: +The alias feels much more intuitive. She also creates a `last` command to quickly see her most recent checkpoint: -[source,console] +[source,bash] ---- $ git config --global alias.last 'log -1 HEAD' ---- -This way, you can see the last commit easily: +==== Running External Tools +tag::procedure[] -[source,console] ----- -$ git last -commit 66938dae3329c7aebe598c2246a8e6af90d04646 -Author: Josh Goebel <dreamer3@example.com> -Date: Tue Aug 26 19:48:51 2008 +0800 - - Test for current head - - Signed-off-by: Scott Chacon <schacon@example.com> ----- - -As you can tell, Git simply replaces the new command with whatever you alias it for. -However, maybe you want to run an external command, rather than a Git subcommand. -In that case, you start the command with a `!` character. -This is useful if you write your own tools that work with a Git repository. -We can demonstrate by aliasing `git visual` to run `gitk`: +You can even create aliases that run external shell commands by starting the command with a `!` character. This is useful if Nora has a custom script that generates a design report from her Git history: -[source,console] +[source,bash] ---- -$ git config --global alias.visual '!gitk' +$ git config --global alias.report '!./scripts/generate-design-report.sh' ---- + +Aliases are a great way to customize Git so it speaks your language and fits your personal design workflow. diff --git a/book/02-git-basics/sections/getting-a-repository.asc b/book/02-git-basics/sections/getting-a-repository.asc index 3b69efd08..214c901e5 100644 --- a/book/02-git-basics/sections/getting-a-repository.asc +++ b/book/02-git-basics/sections/getting-a-repository.asc @@ -1,87 +1,69 @@ [[_getting_a_repo]] === Getting a Git Repository +tag::concept[] -You typically obtain a Git repository in one of two ways: +(((getting a repository))) +For Nora at SketchSpark, the transition to Git starts with her existing research folder. She typically obtains a Git repository in one of two ways: -1. You can take a local directory that is currently not under version control, and turn it into a Git repository, or -2. You can _clone_ an existing Git repository from elsewhere. +1. **Initialize locally:** She can take her current `sketchspark-research` directory and turn it into a Git repository. +2. **Clone from elsewhere:** When Sam joins later, he will get a copy of Nora's repository by "cloning" it from a server. In either case, you end up with a Git repository on your local machine, ready for work. ==== Initializing a Repository in an Existing Directory +tag::procedure[] -If you have a project directory that is currently not under version control and you want to start controlling it with Git, you first need to go to that project's directory. -If you've never done this, it looks a little different depending on which system you're running: +(((git commands, init))) +If Nora wants to start version-controlling her research files, she first needs to navigate to that project's directory in her terminal: -for Linux: -[source,console] +[source,bash] ---- -$ cd /home/user/my_project ----- -for macOS: -[source,console] ----- -$ cd /Users/user/my_project ----- -for Windows: -[source,console] ----- -$ cd C:/Users/user/my_project +$ cd /Users/nora/Documents/sketchspark ---- -and type: +Once inside, she runs the command that starts it all: -[source,console] +[source,bash] ---- $ git init ---- -This creates a new subdirectory named `.git` that contains all of your necessary repository files -- a Git repository skeleton. -At this point, nothing in your project is tracked yet. -See <<ch10-git-internals#ch10-git-internals>> for more information about exactly what files are contained in the `.git` directory you just created.(((git commands, init))) +This creates a new subdirectory named `.git` that contains all of your necessary repository files—the "brain" of your version control system. At this point, nothing in your project is tracked yet; Git knows the files exist, but it isn't watching them for changes. -If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit. -You can accomplish that with a few `git add` commands that specify the files you want to track, followed by a `git commit`: +If Nora wants to start version-controlling her existing files, she needs to begin tracking them and do an initial "checkpoint" (commit). She can accomplish that with a few `git add` commands followed by a `git commit`: -[source,console] +[source,bash] ---- -$ git add *.c -$ git add LICENSE -$ git commit -m 'Initial project version' +$ git add product-brief.md +$ git add research/ +$ git commit -m "[Research: Product] Initial project version" ---- -We'll go over what these commands do in just a minute. -At this point, you have a Git repository with tracked files and an initial commit. +We’ll go over exactly what these commands do in just a minute. At this point, Nora has a real Git repository with tracked files and her first historical checkpoint. [[_git_cloning]] ==== Cloning an Existing Repository +tag::concept[] + +(((git commands, clone))) +If you want to get a copy of an existing Git repository—for example, if you're a designer joining a project that Nora has already started—the command you need is `git clone`. -If you want to get a copy of an existing Git repository -- for example, a project you'd like to contribute to -- the command you need is `git clone`. -If you're familiar with other VCSs such as Subversion, you'll notice that the command is "clone" and not "checkout". -This is an important distinction -- instead of getting just a working copy, Git receives a full copy of nearly all data that the server has. -Every version of every file for the history of the project is pulled down by default when you run `git clone`. -In fact, if your server disk gets corrupted, you can often use nearly any of the clones on any client to set the server back to the state it was in when it was cloned (you may lose some server-side hooks and such, but all the versioned data would be there -- see <<ch04-git-on-the-server#_getting_git_on_a_server>> for more details). +If you're familiar with other version control systems, you'll notice that the command is "clone" and not "checkout." This is an important distinction: instead of getting just the latest version of the files, Git receives a full copy of nearly all data that the server has. Every version of every research note, every persona update, and every journey map in the project's history is pulled down by default. -You clone a repository with `git clone <url>`.(((git commands, clone))) -For example, if you want to clone the Git linkable library called `libgit2`, you can do so like this: +You clone a repository with `git clone <url>`: -[source,console] +[source,bash] ---- -$ git clone https://github.com/libgit2/libgit2 +$ git clone https://github.com/sketchspark/sketchspark ---- -That creates a directory named `libgit2`, initializes a `.git` directory inside it, pulls down all the data for that repository, and checks out a working copy of the latest version. -If you go into the new `libgit2` directory that was just created, you'll see the project files in there, ready to be worked on or used. +This creates a directory named `sketchspark`, initializes a `.git` directory inside it, pulls down all the data, and checks out a "working copy" of the latest version. If you go into that new directory, you'll see the project files ready for work. -If you want to clone the repository into a directory named something other than `libgit2`, you can specify the new directory name as an additional argument: +If you want to clone the repository into a directory named something else, you can specify the new name as an additional argument: -[source,console] +[source,bash] ---- -$ git clone https://github.com/libgit2/libgit2 mylibgit +$ git clone https://github.com/sketchspark/sketchspark my-design-project ---- -That command does the same thing as the previous one, but the target directory is called `mylibgit`. - -Git has a number of different transfer protocols you can use. -The previous example uses the `https://` protocol, but you may also see `git://` or `user@server:path/to/repo.git`, which uses the SSH transfer protocol. -<<ch04-git-on-the-server#_getting_git_on_a_server>> will introduce all of the available options the server can set up to access your Git repository and the pros and cons of each. +Git supports several transfer protocols. While we used `https://` here, you might also see `git://` or `user@server:path/to/repo.git` (which uses SSH). We’ll dive deeper into these in <<ch04-git-on-the-server#ch04-git-on-the-server>>. diff --git a/book/02-git-basics/sections/recording-changes.asc b/book/02-git-basics/sections/recording-changes.asc index 8bcd785fe..deb9327d1 100644 --- a/book/02-git-basics/sections/recording-changes.asc +++ b/book/02-git-basics/sections/recording-changes.asc @@ -1,629 +1,240 @@ === Recording Changes to the Repository +tag::concept[] -At this point, you should have a _bona fide_ Git repository on your local machine, and a checkout or _working copy_ of all of its files in front of you. -Typically, you'll want to start making changes and committing snapshots of those changes into your repository each time the project reaches a state you want to record. +At this point, Nora has a _bona fide_ Git repository for SketchSpark. She has her "working copy" of the project files in front of her. Now, she wants to start making changes and committing "checkpoints" (snapshots) of those changes into her repository each time the project reaches a state she wants to record. -Remember that each file in your working directory can be in one of two states: _tracked_ or _untracked_. -Tracked files are files that were in the last snapshot, as well as any newly staged files; they can be unmodified, modified, or staged. -In short, tracked files are files that Git knows about. +Remember that each file in your project can be in one of two states: **tracked** or **untracked**. -Untracked files are everything else -- any files in your working directory that were not in your last snapshot and are not in your staging area. -When you first clone a repository, all of your files will be tracked and unmodified because Git just checked them out and you haven't edited anything. +* **Tracked files** are those that Git already knows about. They were in your last checkpoint, or you've specifically told Git to start watching them. They can be unmodified, modified, or staged. +* **Untracked files** are everything else—files in your directory that Git hasn't been told to watch yet. -As you edit files, Git sees them as modified, because you've changed them since your last commit. -As you work, you selectively stage these modified files and then commit all those staged changes, and the cycle repeats. +When you first initialize a repo, all your files are untracked. As you work, you selectively "stage" files you've modified and then "commit" all those staged changes into a new checkpoint. Then the cycle repeats. -.The lifecycle of the status of your files +.The lifecycle of your design files in Git image::images/lifecycle.png[The lifecycle of the status of your files] [[_checking_status]] ==== Checking the Status of Your Files +tag::procedure[] -The main tool you use to determine which files are in which state is the `git status` command.(((git commands, status))) -If you run this command directly after a clone, you should see something like this: +(((git commands, status))) +The main tool Nora uses to determine which files are in which state is the `git status` command. If she runs this command immediately after initializing her repo, she might see something like this: -[source,console] +[source,bash] ---- $ git status -On branch master -Your branch is up-to-date with 'origin/master'. -nothing to commit, working tree clean ----- - -This means you have a clean working directory; in other words, none of your tracked files are modified. -Git also doesn't see any untracked files, or they would be listed here. -Finally, the command tells you which branch you're on and informs you that it has not diverged from the same branch on the server. -For now, that branch is always `master`, which is the default; you won't worry about it here. -<<ch03-git-branching#ch03-git-branching>> will go over branches and references in detail. - -[NOTE] -==== -GitHub changed the default branch name from `master` to `main` in mid-2020, and other Git hosts followed suit. -So you may find that the default branch name in some newly created repositories is `main` and not `master`. -In addition, the default branch name can be changed (as you have seen in <<ch01-getting-started#_new_default_branch>>), so you may see a different name for the default branch. - -However, Git itself still uses `master` as the default, so we will use it throughout the book. -==== - -Let's say you add a new file to your project, a simple `README` file. -If the file didn't exist before, and you run `git status`, you see your untracked file like so: - -[source,console] ----- -$ echo 'My Project' > README -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. +On branch main +No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) - README + product-brief.md + research/ nothing added to commit but untracked files present (use "git add" to track) ---- -You can see that your new `README` file is untracked, because it's under the "`Untracked files`" heading in your status output. -Untracked basically means that Git sees a file you didn't have in the previous snapshot (commit), and which hasn't yet been staged; Git won't start including it in your commit snapshots until you explicitly tell it to do so. -It does this so you don't accidentally begin including generated binary files or other files that you did not mean to include. -You do want to start including `README`, so let's start tracking the file. +This means Nora has a "clean" branch with no commits yet, but she has several untracked files: her product brief and the entire research directory. Git sees them but won't include them in a checkpoint until she explicitly says so. [[_tracking_files]] ==== Tracking New Files +tag::procedure[] -In order to begin tracking a new file, you use the command `git add`.(((git commands, add))) -To begin tracking the `README` file, you can run this: +(((git commands, add))) +In order to begin tracking a new file, Nora uses the `git add` command. To start tracking her `product-brief.md`, she runs: -[source,console] +[source,bash] ---- -$ git add README +$ git add product-brief.md ---- -If you run your status command again, you can see that your `README` file is now tracked and staged to be committed: +Now, if she runs `git status` again, she sees that the file is **staged** and ready to be committed: -[source,console] +[source,bash] ---- $ git status -On branch master -Your branch is up-to-date with 'origin/master'. +On branch main +No commits yet Changes to be committed: - (use "git restore --staged <file>..." to unstage) + (use "git rm --cached <file>..." to unstage) - new file: README + new file: product-brief.md +Untracked files: + (use "git add <file>..." to include in what will be committed) + + research/ ---- -You can tell that it's staged because it's under the "`Changes to be committed`" heading. -If you commit at this point, the version of the file at the time you ran `git add` is what will be in the subsequent historical snapshot. -You may recall that when you ran `git init` earlier, you then ran `git add <files>` -- that was to begin tracking files in your directory.(((git commands, init)))(((git commands, add))) -The `git add` command takes a path name for either a file or a directory; if it's a directory, the command adds all the files in that directory recursively. +The file is now under the "Changes to be committed" heading. This is the **Staging Area**. It's like a shopping cart: you've picked the items you want to buy (commit), but you haven't checked out yet. ==== Staging Modified Files +tag::procedure[] -Let's change a file that was already tracked. -If you change a previously tracked file called `CONTRIBUTING.md` and then run your `git status` command again, you get something that looks like this: +Let's say Nora edits `product-brief.md` to add a new section on "Competitors." Now she has a file that is both tracked and modified. If she runs `git status`, it looks like this: -[source,console] +[source,bash] ---- $ git status -On branch master -Your branch is up-to-date with 'origin/master'. +On branch main Changes to be committed: - (use "git reset HEAD <file>..." to unstage) + (use "git rm --cached <file>..." to unstage) - new file: README + new file: product-brief.md Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) - modified: CONTRIBUTING.md - ----- - -The `CONTRIBUTING.md` file appears under a section named "`Changes not staged for commit`" -- which means that a file that is tracked has been modified in the working directory but not yet staged. -To stage it, you run the `git add` command. -`git add` is a multipurpose command -- you use it to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved. -It may be helpful to think of it more as "`add precisely this content to the next commit`" rather than "`add this file to the project`".(((git commands, add))) -Let's run `git add` now to stage the `CONTRIBUTING.md` file, and then run `git status` again: - -[source,console] ----- -$ git add CONTRIBUTING.md -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - new file: README - modified: CONTRIBUTING.md - + modified: product-brief.md ---- -Both files are staged and will go into your next commit. -At this point, suppose you remember one little change that you want to make in `CONTRIBUTING.md` before you commit it. -You open it again and make that change, and you're ready to commit. -However, let's run `git status` one more time: +Wait—why is it in both places? Because Git stages a file *exactly as it was* when you ran `git add`. If you modify a file after staging it, you have to run `git add` again to stage the latest version. -[source,console] +[source,bash] ---- -$ vim CONTRIBUTING.md +$ git add product-brief.md $ git status -On branch master -Your branch is up-to-date with 'origin/master'. +On branch main Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - new file: README - modified: CONTRIBUTING.md - -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: CONTRIBUTING.md - ----- - -What the heck? -Now `CONTRIBUTING.md` is listed as both staged _and_ unstaged. -How is that possible? -It turns out that Git stages a file exactly as it is when you run the `git add` command. -If you commit now, the version of `CONTRIBUTING.md` as it was when you last ran the `git add` command is how it will go into the commit, not the version of the file as it looks in your working directory when you run `git commit`. -If you modify a file after you run `git add`, you have to run `git add` again to stage the latest version of the file: - -[source,console] + new file: product-brief.md ---- -$ git add CONTRIBUTING.md -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - new file: README - modified: CONTRIBUTING.md ----- +Now the latest version is staged and ready for the checkpoint. ==== Short Status +tag::reference[] -While the `git status` output is pretty comprehensive, it's also quite wordy. -Git also has a short status flag so you can see your changes in a more compact way. -If you run `git status -s` or `git status --short` you get a far more simplified output from the command: +If `git status` feels too wordy, you can use the `-s` or `--short` flag: -[source,console] +[source,bash] ---- $ git status -s - M README -MM Rakefile -A lib/git.rb -M lib/simplegit.rb -?? LICENSE.txt + M product-brief.md +?? research/ ---- -New files that aren't tracked have a `??` next to them, new files that have been added to the staging area have an `A`, modified files have an `M` and so on. -There are two columns to the output -- the left-hand column indicates the status of the staging area and the right-hand column indicates the status of the working tree. -So for example in that output, the `README` file is modified in the working directory but not yet staged, while the `lib/simplegit.rb` file is modified and staged. -The `Rakefile` was modified, staged and then modified again, so there are changes to it that are both staged and unstaged. +* `??` = Untracked files. +* `A` = Added to the staging area. +* `M` = Modified. + * `M` in the first column means it is staged. + * `M` in the second column means it is modified but not yet staged. -[[_ignoring]] ==== Ignoring Files +tag::config[] -Often, you'll have a class of files that you don't want Git to automatically add or even show you as being untracked. -These are generally automatically generated files such as log files or files produced by your build system. -In such cases, you can create a file listing patterns to match them named `.gitignore`.(((ignoring files))) -Here is an example `.gitignore` file: - -[source,console] ----- -$ cat .gitignore -*.[oa] -*~ ----- - -The first line tells Git to ignore any files ending in "`.o`" or "`.a`" -- object and archive files that may be the product of building your code. -The second line tells Git to ignore all files whose names end with a tilde (`~`), which is used by many text editors such as Emacs to mark temporary files. -You may also include a log, tmp, or pid directory; automatically generated documentation; and so on. -Setting up a `.gitignore` file for your new repository before you get going is generally a good idea so you don't accidentally commit files that you really don't want in your Git repository. - -The rules for the patterns you can put in the `.gitignore` file are as follows: +(((git commands, .gitignore))) +Nora notices that her `git status` is cluttered with `.DS_Store` files and temporary files created by her design tools (like `sketch-input.figma_cache`). She doesn't want to version-control these. -* Blank lines or lines starting with `#` are ignored. -* Standard glob patterns work, and will be applied recursively throughout the entire working tree. -* You can start patterns with a forward slash (`/`) to avoid recursivity. -* You can end patterns with a forward slash (`/`) to specify a directory. -* You can negate a pattern by starting it with an exclamation point (`!`). +She creates a file named `.gitignore` in her project root and lists patterns for files she wants Git to ignore: -Glob patterns are like simplified regular expressions that shells use. -An asterisk (`\*`) matches zero or more characters; `[abc]` matches any character inside the brackets (in this case a, b, or c); a question mark (`?`) matches a single character; and brackets enclosing characters separated by a hyphen (`[0-9]`) matches any character between them (in this case 0 through 9). -You can also use two asterisks to match nested directories; `a/**/z` would match `a/z`, `a/b/z`, `a/b/c/z`, and so on. - -Here is another example `.gitignore` file: - -[source] +[source,bash] ---- -# ignore all .a files -*.a - -# but do track lib.a, even though you're ignoring .a files above -!lib.a - -# only ignore the TODO file in the current directory, not subdir/TODO -/TODO - -# ignore all files in any directory named build -build/ - -# ignore doc/notes.txt, but not doc/server/arch.txt -doc/*.txt - -# ignore all .pdf files in the doc/ directory and any of its subdirectories -doc/**/*.pdf +$ cat .gitignore +.DS_Store +__MACOSX/ +*.sketch~ +*.figma_cache +Thumbs.db ---- -[TIP] -==== -GitHub maintains a fairly comprehensive list of good `.gitignore` file examples for dozens of projects and languages at https://github.com/github/gitignore[^] if you want a starting point for your project. -==== +The rules for patterns you can put in the `.gitignore` file are as follows: -[NOTE] -==== -In the simple case, a repository might have a single `.gitignore` file in its root directory, which applies recursively to the entire repository. -However, it is also possible to have additional `.gitignore` files in subdirectories. -The rules in these nested `.gitignore` files apply only to the files under the directory where they are located. -The Linux kernel source repository has 206 `.gitignore` files. +* Blank lines or lines starting with `#` are ignored. +* Standard glob patterns work, and will be applied recursively throughout the entire working tree. +* You can start patterns with a forward slash (`/`) to avoid recursivity. +* You can end patterns with a forward slash (`/`) to specify a directory. +* You can negate a pattern by starting it with an exclamation point (`!`). -It is beyond the scope of this book to get into the details of multiple `.gitignore` files; see `man gitignore` for the details. -==== +For designers, a good `.gitignore` is essential for keeping the repository clean of "junk" files that don't need to be shared with the team. -[[_git_diff_staged]] ==== Viewing Your Staged and Unstaged Changes +tag::concept[] -If the `git status` command is too vague for you -- you want to know exactly what you changed, not just which files were changed -- you can use the `git diff` command.(((git commands, diff))) -We'll cover `git diff` in more detail later, but you'll probably use it most often to answer these two questions: What have you changed but not yet staged? -And what have you staged that you are about to commit? -Although `git status` answers those questions very generally by listing the file names, `git diff` shows you the exact lines added and removed -- the patch, as it were. - -Let's say you edit and stage the `README` file again and then edit the `CONTRIBUTING.md` file without staging it. -If you run your `git status` command, you once again see something like this: - -[source,console] ----- -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - modified: README +(((git commands, diff))) +If the `git status` command is too vague—telling you only that a file has changed—you can use `git diff` to see exactly *what* changed. -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) +To see what you've changed but not yet staged, type `git diff` by itself. This compares what is in your working directory with what is in your staging area. - modified: CONTRIBUTING.md ----- - -To see what you've changed but not yet staged, type `git diff` with no other arguments: +If Nora adds a "Vision" statement to the brief but hasn't staged it yet: -[source,console] +[source,bash] ---- $ git diff -diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md -index 8ebb991..643e24f 100644 ---- a/CONTRIBUTING.md -+++ b/CONTRIBUTING.md -@@ -65,7 +65,8 @@ branch directly, things can get messy. - Please include a nice description of your changes when you submit your PR; - if we have to read the whole diff to figure out why you're contributing - in the first place, you're less likely to get feedback and have your change --merged in. -+merged in. Also, split your changes into comprehensive chunks if your patch is -+longer than a dozen lines. - - If you are starting to work on a particular area, feel free to submit a PR - that highlights your work in progress (and note in the PR title that it's +diff --git a/product-brief.md b/product-brief.md +index 1234567..89abcde 100644 +--- a/product-brief.md ++++ b/product-brief.md +@@ -1,5 +1,6 @@ + # SketchSpark Product Brief + ++## Vision ++SketchSpark is an AI-powered rapid prototyping application... ---- -That command compares what is in your working directory with what is in your staging area. -The result tells you the changes you've made that you haven't yet staged. +To see what you have staged that will go into your next commit, you can use `git diff --staged` (or `git diff --cached`): -If you want to see what you've staged that will go into your next commit, you can use `git diff --staged`. -This command compares your staged changes to your last commit: - -[source,console] +[source,bash] ---- $ git diff --staged -diff --git a/README b/README -new file mode 100644 -index 0000000..03902a1 ---- /dev/null -+++ b/README -@@ -0,0 +1 @@ -+My Project ---- -It's important to note that `git diff` by itself doesn't show all changes made since your last commit -- only changes that are still unstaged. -If you've staged all of your changes, `git diff` will give you no output. - -For another example, if you stage the `CONTRIBUTING.md` file and then edit it, you can use `git diff` to see the changes in the file that are staged and the changes that are unstaged. -If our environment looks like this: +**Note on Binary Files:** If Nora runs `git diff` on a modified PNG or Figma file, Git will simply tell her "Binary files differ." It can't show a line-by-line diff of an image. We’ll cover how to handle these better in <<ch08-customizing-git#ch08-customizing-git>>. -[source,console] ----- -$ git add CONTRIBUTING.md -$ echo '# test line' >> CONTRIBUTING.md -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - modified: CONTRIBUTING.md - -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: CONTRIBUTING.md ----- - -Now you can use `git diff` to see what is still unstaged: - -[source,console] ----- -$ git diff -diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md -index 643e24f..87f08c8 100644 ---- a/CONTRIBUTING.md -+++ b/CONTRIBUTING.md -@@ -119,3 +119,4 @@ at the - ## Starter Projects - - See our [projects list](https://github.com/libgit2/libgit2/blob/development/PROJECTS.md). -+# test line ----- - -and `git diff --cached` to see what you've staged so far (`--staged` and `--cached` are synonyms): - -[source,console] ----- -$ git diff --cached -diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md -index 8ebb991..643e24f 100644 ---- a/CONTRIBUTING.md -+++ b/CONTRIBUTING.md -@@ -65,7 +65,8 @@ branch directly, things can get messy. - Please include a nice description of your changes when you submit your PR; - if we have to read the whole diff to figure out why you're contributing - in the first place, you're less likely to get feedback and have your change --merged in. -+merged in. Also, split your changes into comprehensive chunks if your patch is -+longer than a dozen lines. - - If you are starting to work on a particular area, feel free to submit a PR - that highlights your work in progress (and note in the PR title that it's ----- - -[NOTE] -.Git Diff in an External Tool -==== -We will continue to use the `git diff` command in various ways throughout the rest of the book. -There is another way to look at these diffs if you prefer a graphical or external diff viewing program instead. -If you run `git difftool` instead of `git diff`, you can view any of these diffs in software like emerge, vimdiff and many more (including commercial products). -Run `git difftool --tool-help` to see what is available on your system. -==== - -[[_committing_changes]] ==== Committing Your Changes +tag::procedure[] -Now that your staging area is set up the way you want it, you can commit your changes. -Remember that anything that is still unstaged -- any files you have created or modified that you haven't run `git add` on since you edited them -- won't go into this commit. -They will stay as modified files on your disk. -In this case, let's say that the last time you ran `git status`, you saw that everything was staged, so you're ready to commit your changes.(((git commands, status))) -The simplest way to commit is to type `git commit`:(((git commands, commit))) +(((git commands, commit))) +Once Nora's staging area is set up exactly how she wants it, she can commit her changes. This creates a permanent checkpoint in the project's history. -[source,console] +[source,bash] ---- $ git commit ---- -Doing so launches your editor of choice. +This launches her configured editor (like VS Code) so she can type a commit message. Following the SketchSpark team's convention, she writes: -[NOTE] -==== -This is set by your shell's `EDITOR` environment variable -- usually vim or emacs, although you can configure it with whatever you want using the `git config --global core.editor` command as you saw in <<ch01-getting-started#ch01-getting-started>>.(((editor, changing default)))(((git commands, config))) -==== - -The editor displays the following text (this example is a Vim screen): - -[source] +[source,text] ---- +[Research: Product] Add initial vision and core features -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit. -# On branch master -# Your branch is up-to-date with 'origin/master'. -# -# Changes to be committed: -# new file: README -# modified: CONTRIBUTING.md -# -~ -~ -~ -".git/COMMIT_EDITMSG" 9L, 283C +This brief outlines the core AI pipeline and target audience for the +initial SketchSpark prototype. ---- -You can see that the default commit message contains the latest output of the `git status` command commented out and one empty line on top. -You can remove these comments and type your commit message, or you can leave them there to help you remember what you're committing. - -[NOTE] -==== -For an even more explicit reminder of what you've modified, you can pass the `-v` option to `git commit`. -Doing so also puts the diff of your change in the editor so you can see exactly what changes you're committing. -==== - -When you exit the editor, Git creates your commit with that commit message (with the comments and diff stripped out). +Alternatively, for simple messages, she can use the `-m` flag: -Alternatively, you can type your commit message inline with the `commit` command by specifying it after a `-m` flag, like this: - -[source,console] +[source,bash] ---- -$ git commit -m "Story 182: fix benchmarks for speed" -[master 463dc4f] Story 182: fix benchmarks for speed - 2 files changed, 2 insertions(+) - create mode 100644 README +$ git commit -m "[Research: Product] Add initial vision and core features" ---- -Now you've created your first commit! -You can see that the commit has given you some output about itself: which branch you committed to (`master`), what SHA-1 checksum the commit has (`463dc4f`), how many files were changed, and statistics about lines added and removed in the commit. - -Remember that the commit records the snapshot you set up in your staging area. -Anything you didn't stage is still sitting there modified; you can do another commit to add it to your history. -Every time you perform a commit, you're recording a snapshot of your project that you can revert to or compare to later. +Now Nora has her first official checkpoint! Git tells her which branch she committed to, the SHA-1 hash of the commit, and a summary of how many files changed. -==== Skipping the Staging Area +==== Removing and Moving Files +tag::procedure[] -(((staging area, skipping))) -Although it can be amazingly useful for crafting commits exactly how you want them, the staging area is sometimes a bit more complex than you need in your workflow. -If you want to skip the staging area, Git provides a simple shortcut. -Adding the `-a` option to the `git commit` command makes Git automatically stage every file that is already tracked before doing the commit, letting you skip the `git add` part: +(((git commands, rm))) +(((git commands, mv))) +If Nora needs to remove a file from Git, she uses `git rm`. This removes the file from her tracked files and also deletes it from her working directory so she doesn't see it as an untracked file next time. -[source,console] +[source,bash] ---- -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: CONTRIBUTING.md - -no changes added to commit (use "git add" and/or "git commit -a") -$ git commit -a -m 'Add new benchmarks' -[master 83e38c7] Add new benchmarks - 1 file changed, 5 insertions(+), 0 deletions(-) +$ git rm research/old-notes.md ---- -Notice how you don't have to run `git add` on the `CONTRIBUTING.md` file in this case before you commit. -That's because the `-a` flag includes all changed files. -This is convenient, but be careful; sometimes this flag will cause you to include unwanted changes. - -[[_removing_files]] -==== Removing Files - -(((files, removing))) -To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. -The `git rm` command does that, and also removes the file from your working directory so you don't see it as an untracked file the next time around. - -If you simply remove the file from your working directory, it shows up under the "`Changes not staged for commit`" (that is, _unstaged_) area of your `git status` output: - -[source,console] ----- -$ rm PROJECTS.md -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes not staged for commit: - (use "git add/rm <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - deleted: PROJECTS.md +If she wants to keep the file on her computer but stop tracking it in Git (useful if she accidentally added a large binary file), she uses the `--cached` flag: -no changes added to commit (use "git add" and/or "git commit -a") +[source,bash] ---- - -Then, if you run `git rm`, it stages the file's removal: - -[source,console] ----- -$ git rm PROJECTS.md -rm 'PROJECTS.md' -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - deleted: PROJECTS.md ----- - -The next time you commit, the file will be gone and no longer tracked. -If you modified the file or had already added it to the staging area, you must force the removal with the `-f` option. -This is a safety feature to prevent accidental removal of data that hasn't yet been recorded in a snapshot and that can't be recovered from Git. - -Another useful thing you may want to do is to keep the file in your working tree but remove it from your staging area. -In other words, you may want to keep the file on your hard drive but not have Git track it anymore. -This is particularly useful if you forgot to add something to your `.gitignore` file and accidentally staged it, like a large log file or a bunch of `.a` compiled files. -To do this, use the `--cached` option: - -[source,console] ----- -$ git rm --cached README ----- - -You can pass files, directories, and file-glob patterns to the `git rm` command. -That means you can do things such as: - -[source,console] ----- -$ git rm log/\*.log ----- - -Note the backslash (`\`) in front of the `*`. -This is necessary because Git does its own filename expansion in addition to your shell's filename expansion. -This command removes all files that have the `.log` extension in the `log/` directory. -Or, you can do something like this: - -[source,console] ----- -$ git rm \*~ ----- - -This command removes all files whose names end with a `~`. - -[[_git_mv]] -==== Moving Files - -(((files, moving))) -Unlike many other VCSs, Git doesn't explicitly track file movement. -If you rename a file in Git, no metadata is stored in Git that tells it you renamed the file. -However, Git is pretty smart about figuring that out after the fact -- we'll deal with detecting file movement a bit later. - -Thus it's a bit confusing that Git has a `mv` command. -If you want to rename a file in Git, you can run something like: - -[source,console] ----- -$ git mv file_from file_to ----- - -and it works fine. -In fact, if you run something like this and look at the status, you'll see that Git considers it a renamed file: - -[source,console] ----- -$ git mv README.md README -$ git status -On branch master -Your branch is up-to-date with 'origin/master'. -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - renamed: README.md -> README +$ git rm --cached oversized-asset.psd ---- -However, this is equivalent to running something like this: +To move or rename a file, she uses `git mv`: -[source,console] +[source,bash] ---- -$ mv README.md README -$ git rm README.md -$ git add README +$ git mv product-brief.md vision.md ---- -Git figures out that it's a rename implicitly, so it doesn't matter if you rename a file that way or with the `mv` command. -The only real difference is that `git mv` is one command instead of three -- it's a convenience function. -More importantly, you can use any tool you like to rename a file, and address the `add`/`rm` later, before you commit. +Git is smart enough to realize this is a rename even if you just use standard `mv` and then `git add`, but `git mv` is a convenient shorthand. diff --git a/book/02-git-basics/sections/remotes.asc b/book/02-git-basics/sections/remotes.asc index 80e98250a..bcaa7aa17 100644 --- a/book/02-git-basics/sections/remotes.asc +++ b/book/02-git-basics/sections/remotes.asc @@ -1,240 +1,92 @@ -[[_remote_repos]] === Working with Remotes +tag::concept[] -To be able to collaborate on any Git project, you need to know how to manage your remote repositories. -Remote repositories are versions of your project that are hosted on the Internet or network somewhere. -You can have several of them, each of which generally is either read-only or read/write for you. -Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work. -Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more. -In this section, we'll cover some of these remote-management skills. - -[NOTE] -.Remote repositories can be on your local machine. -==== -It is entirely possible that you can be working with a "`remote`" repository that is, in fact, on the same host you are. -The word "`remote`" does not necessarily imply that the repository is somewhere else on the network or Internet, only that it is elsewhere. -Working with such a remote repository would still involve all the standard pushing, pulling and fetching operations as with any other remote. -==== +(((remote repositories))) +To be able to collaborate on any Git project, you need to know how to manage your remote repositories. Remote repositories are versions of your project that are hosted on the Internet or a network somewhere. + +Collaborating with others involves pushing and pulling data to and from these remotes when you need to share work. While Nora is currently working solo on SketchSpark, she knows that she’ll soon need to share her research with Sam and Priya. ==== Showing Your Remotes +tag::procedure[] -To see which remote servers you have configured, you can run the `git remote` command.(((git commands, remote))) -It lists the shortnames of each remote handle you've specified. -If you've cloned your repository, you should at least see `origin` -- that is the default name Git gives to the server you cloned from: +(((git commands, remote))) +To see which remote servers you have configured, you can run the `git remote` command. If Nora has just initialized her project locally, she won’t see anything yet: -[source,console] +[source,bash] ---- -$ git clone https://github.com/schacon/ticgit -Cloning into 'ticgit'... -remote: Reusing existing pack: 1857, done. -remote: Total 1857 (delta 0), reused 0 (delta 0) -Receiving objects: 100% (1857/1857), 374.35 KiB | 268.00 KiB/s, done. -Resolving deltas: 100% (772/772), done. -Checking connectivity... done. -$ cd ticgit $ git remote -origin ---- -You can also specify `-v`, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote: +However, if she had cloned the project from a server, she would see `origin`—the default name Git gives to the server you cloned from. -[source,console] ----- -$ git remote -v -origin https://github.com/schacon/ticgit (fetch) -origin https://github.com/schacon/ticgit (push) ----- +To see the URLs associated with each remote, use the `-v` flag: -If you have more than one remote, the command lists them all. -For example, a repository with multiple remotes for working with several collaborators might look something like this. - -[source,console] +[source,bash] ---- -$ cd grit $ git remote -v -bakkdoor https://github.com/bakkdoor/grit (fetch) -bakkdoor https://github.com/bakkdoor/grit (push) -cho45 https://github.com/cho45/grit (fetch) -cho45 https://github.com/cho45/grit (push) -defunkt https://github.com/defunkt/grit (fetch) -defunkt https://github.com/defunkt/grit (push) -koke git://github.com/koke/grit.git (fetch) -koke git://github.com/koke/grit.git (push) -origin git@github.com:mojombo/grit.git (fetch) -origin git@github.com:mojombo/grit.git (push) ---- -This means we can pull contributions from any of these users pretty easily. -We may additionally have permission to push to one or more of these, though we can't tell that here. - -Notice that these remotes use a variety of protocols; we'll cover more about this in <<ch04-git-on-the-server#_getting_git_on_a_server>>. - ==== Adding Remote Repositories +tag::procedure[] -We've mentioned and given some demonstrations of how the `git clone` command implicitly adds the `origin` remote for you. -Here's how to add a new remote explicitly.(((git commands, remote))) -To add a new remote Git repository as a shortname you can reference easily, run `git remote add <shortname> <url>`: - -[source,console] ----- -$ git remote -origin -$ git remote add pb https://github.com/paulboone/ticgit -$ git remote -v -origin https://github.com/schacon/ticgit (fetch) -origin https://github.com/schacon/ticgit (push) -pb https://github.com/paulboone/ticgit (fetch) -pb https://github.com/paulboone/ticgit (push) ----- - -Now you can use the string `pb` on the command line instead of the whole URL. -For example, if you want to fetch all the information that Paul has but that you don't yet have in your repository, you can run `git fetch pb`: +Suppose Nora sets up a private space on GitHub for the SketchSpark team. To add this as a remote she can reference easily, she runs: -[source,console] +[source,bash] ---- -$ git fetch pb -remote: Counting objects: 43, done. -remote: Compressing objects: 100% (36/36), done. -remote: Total 43 (delta 10), reused 31 (delta 5) -Unpacking objects: 100% (43/43), done. -From https://github.com/paulboone/ticgit - * [new branch] master -> pb/master - * [new branch] ticgit -> pb/ticgit +$ git remote add origin https://github.com/sketchspark/sketchspark.git ---- -Paul's `master` branch is now accessible locally as `pb/master` -- you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it. -We'll go over what branches are and how to use them in much more detail in <<ch03-git-branching#ch03-git-branching>>. +Now Nora can use the string `origin` instead of the whole URL whenever she wants to interact with the server. -[[_fetching_and_pulling]] ==== Fetching and Pulling from Your Remotes +tag::procedure[] -As you just saw, to get data from your remote projects, you can run:(((git commands, fetch))) +(((git commands, fetch))) +(((git commands, pull))) +To get data from your remote project, you use `git fetch origin`. This downloads all the data from the server that you don't yet have. It’s important to note that `git fetch` only downloads the data—it doesn't automatically merge it with your current work. You have to do that manually. -[source,console] +If you want Git to both fetch and automatically merge the remote changes into your current branch, use `git pull`: + +[source,bash] ---- -$ git fetch <remote> +$ git pull origin main ---- -The command goes out to that remote project and pulls down all the data from that remote project that you don't have yet. -After you do this, you should have references to all the branches from that remote, which you can merge in or inspect at any time. - -If you clone a repository, the command automatically adds that remote repository under the name "`origin`". -So, `git fetch origin` fetches any new work that has been pushed to that server since you cloned (or last fetched from) it. -It's important to note that the `git fetch` command only downloads the data to your local repository -- it doesn't automatically merge it with any of your work or modify what you're currently working on. -You have to merge it manually into your work when you're ready. - -If your current branch is set up to track a remote branch (see the next section and <<ch03-git-branching#ch03-git-branching>> for more information), you can use the `git pull` command to automatically fetch and then merge that remote branch into your current branch.(((git commands, pull))) -This may be an easier or more comfortable workflow for you; and by default, the `git clone` command automatically sets up your local `master` branch to track the remote `master` branch (or whatever the default branch is called) on the server you cloned from. -Running `git pull` generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you're currently working on. - -[NOTE] -==== -From Git version 2.27 onward, `git pull` will give a warning if the `pull.rebase` variable is not set. -Git will keep warning you until you set the variable. +For designers, `git pull` is the morning ritual: "What did my teammates update while I was away?" -If you want the default behavior of Git (fast-forward if possible, else create a merge commit): -`git config --global pull.rebase "false"` - -If you want to rebase when pulling: -`git config --global pull.rebase "true"` -==== - -[[_pushing_remotes]] ==== Pushing to Your Remotes +tag::procedure[] -When you have your project at a point that you want to share, you have to push it upstream. -The command for this is simple: `git push <remote> <branch>`.(((git commands, push))) -If you want to push your `master` branch to your `origin` server (again, cloning generally sets up both of those names for you automatically), then you can run this to push any commits you've done back up to the server: +(((git commands, push))) +When Nora has her research at a point where she wants to share it with the team (or just back it up to the cloud), she "pushes" her changes: -[source,console] +[source,bash] ---- -$ git push origin master +$ git push origin main ---- -This command works only if you cloned from a server to which you have write access and if nobody has pushed in the meantime. -If you and someone else clone at the same time and they push upstream and then you push upstream, your push will rightly be rejected. -You'll have to fetch their work first and incorporate it into yours before you'll be allowed to push. -See <<ch03-git-branching#ch03-git-branching>> for more detailed information on how to push to remote servers. +This command works only if she has write access to the server and if nobody has pushed in the meantime. If Sam has already pushed a new layout, Nora’s push will be rejected until she pulls Sam’s work and integrates it. -[[_inspecting_remote]] -==== Inspecting a Remote +==== Inspecting and Renaming Remotes +tag::reference[] -If you want to see more information about a particular remote, you can use the `git remote show <remote>` command.(((git commands, remote))) -If you run this command with a particular shortname, such as `origin`, you get something like this: +To see more information about a particular remote: -[source,console] +[source,bash] ---- $ git remote show origin -* remote origin - Fetch URL: https://github.com/schacon/ticgit - Push URL: https://github.com/schacon/ticgit - HEAD branch: master - Remote branches: - master tracked - dev-branch tracked - Local branch configured for 'git pull': - master merges with remote master - Local ref configured for 'git push': - master pushes to master (up to date) ---- -It lists the URL for the remote repository as well as the tracking branch information. -The command helpfully tells you that if you're on the `master` branch and you run `git pull`, it will automatically merge the remote's `master` branch into the local one after it has been fetched. -It also lists all the remote references it has pulled down. - -That is a simple example you're likely to encounter. -When you're using Git more heavily, however, you may see much more information from `git remote show`: +To rename a remote (for example, from `pb` to `paul`): -[source,console] ----- -$ git remote show origin -* remote origin - URL: https://github.com/my-org/complex-project - Fetch URL: https://github.com/my-org/complex-project - Push URL: https://github.com/my-org/complex-project - HEAD branch: master - Remote branches: - master tracked - dev-branch tracked - markdown-strip tracked - issue-43 new (next fetch will store in remotes/origin) - issue-45 new (next fetch will store in remotes/origin) - refs/remotes/origin/issue-11 stale (use 'git remote prune' to remove) - Local branches configured for 'git pull': - dev-branch merges with remote dev-branch - master merges with remote master - Local refs configured for 'git push': - dev-branch pushes to dev-branch (up to date) - markdown-strip pushes to markdown-strip (up to date) - master pushes to master (up to date) ----- - -This command shows which branch is automatically pushed to when you run `git push` while on certain branches. -It also shows you which remote branches on the server you don't yet have, which remote branches you have that have been removed from the server, and multiple local branches that are able to merge automatically with their remote-tracking branch when you run `git pull`. - -==== Renaming and Removing Remotes - -You can run `git remote rename` to change a remote's shortname.(((git commands, remote))) -For instance, if you want to rename `pb` to `paul`, you can do so with `git remote rename`: - -[source,console] +[source,bash] ---- $ git remote rename pb paul -$ git remote -origin -paul ---- -It's worth mentioning that this changes all your remote-tracking branch names, too. -What used to be referenced at `pb/master` is now at `paul/master`. +To remove a remote you’re no longer using: -If you want to remove a remote for some reason -- you've moved the server or are no longer using a particular mirror, or perhaps a contributor isn't contributing anymore -- you can either use `git remote remove` or `git remote rm`: - -[source,console] +[source,bash] ---- $ git remote remove paul -$ git remote -origin ---- - -Once you delete the reference to a remote this way, all remote-tracking branches and configuration settings associated with that remote are also deleted. diff --git a/book/02-git-basics/sections/tagging.asc b/book/02-git-basics/sections/tagging.asc index 34604c573..7551873d1 100644 --- a/book/02-git-basics/sections/tagging.asc +++ b/book/02-git-basics/sections/tagging.asc @@ -1,299 +1,126 @@ -[[_git_tagging]] === Tagging +tag::concept[] (((tags))) -Like most VCSs, Git has the ability to tag specific points in a repository's history as being important. -Typically, people use this functionality to mark release points (`v1.0`, `v2.0` and so on). -In this section, you'll learn how to list existing tags, how to create and delete tags, and what the different types of tags are. +Like most version control systems, Git has the ability to "tag" specific points in a project's history as being important. Typically, people use this to mark release points (`v1.0`, `v2.0` and so on). + +For Nora at SketchSpark, tags are like bookmarks in her project's timeline. She’s just finished the concept phase and wants to mark this exact state of the repo before Sam starts making drastic UI changes. ==== Listing Your Tags +tag::reference[] -Listing the existing tags in Git is straightforward. -Just type `git tag` (with optional `-l` or `--list`):(((git commands, tag))) +(((git commands, tag))) +Listing the existing tags in Git is straightforward. Just type `git tag`: -[source,console] +[source,bash] ---- $ git tag -v1.0 -v2.0 ----- - -This command lists the tags in alphabetical order; the order in which they are displayed has no real importance. - -You can also search for tags that match a particular pattern. -The Git source repo, for instance, contains more than 500 tags. -If you're interested only in looking at the 1.8.5 series, you can run this: - -[source,console] ----- -$ git tag -l "v1.8.5*" -v1.8.5 -v1.8.5-rc0 -v1.8.5-rc1 -v1.8.5-rc2 -v1.8.5-rc3 -v1.8.5.1 -v1.8.5.2 -v1.8.5.3 -v1.8.5.4 -v1.8.5.5 +v0.1-concept ---- -[NOTE] -.Listing tag wildcards requires `-l` or `--list` option -==== -If you want just the entire list of tags, running the command `git tag` implicitly assumes you want a listing and provides one; the use of `-l` or `--list` in this case is optional. - -If, however, you're supplying a wildcard pattern to match tag names, the use of `-l` or `--list` is mandatory. -==== +This command lists the tags in alphabetical order. ==== Creating Tags +tag::procedure[] -Git supports two types of tags: _lightweight_ and _annotated_. +Git supports two types of tags: **lightweight** and **annotated**. -A lightweight tag is very much like a branch that doesn't change -- it's just a pointer to a specific commit. +* A **lightweight tag** is like a branch that doesn’t change—it’s just a pointer to a specific checkpoint. +* An **annotated tag** is stored as a full object in the Git database. It contains the tagger name, email, date, and a message. -Annotated tags, however, are stored as full objects in the Git database. -They're checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). -It's generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don't want to keep the other information, lightweight tags are available too. +It’s generally recommended that you create annotated tags for important milestones so you have all this extra context. -[[_annotated_tags]] ==== Annotated Tags +tag::procedure[] (((tags, annotated))) -Creating an annotated tag in Git is simple. -The easiest way is to specify `-a` when you run the `tag` command:(((git commands, tag))) +To create an annotated tag, Nora uses the `-a` flag: -[source,console] +[source,bash] ---- -$ git tag -a v1.4 -m "my version 1.4" -$ git tag -v0.1 -v1.3 -v1.4 +$ git tag -a v0.1-concept -m "Research complete, concept approved, entering UI exploration" ---- -The `-m` specifies a tagging message, which is stored with the tag. -If you don't specify a message for an annotated tag, Git launches your editor so you can type it in. - -You can see the tag data along with the commit that was tagged by using the `git show` command: +The `-m` specifies a message that is stored with the tag. You can see the tag data along with the commit that was tagged by using the `git show` command: -[source,console] +[source,bash] ---- -$ git show v1.4 -tag v1.4 -Tagger: Ben Straub <ben@straub.cc> -Date: Sat May 3 20:19:12 2014 -0700 +$ git show v0.1-concept +tag v0.1-concept +Tagger: Nora UX <nora@sketchspark.io> +Date: Fri Mar 20 14:30:00 2026 -0700 -my version 1.4 +Research complete, concept approved, entering UI exploration commit ca82a6dff817ec66f44342007202690a93763949 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Mon Mar 17 21:52:11 2008 -0700 +Author: Nora UX <nora@sketchspark.io> +Date: Mon Mar 17 21:52:11 2026 -0700 - Change version number + [Research: Product] Add initial vision and core features ---- -That shows the tagger information, the date the commit was tagged, and the annotation message before showing the commit information. - ==== Lightweight Tags +tag::procedure[] (((tags, lightweight))) -Another way to tag commits is with a lightweight tag. -This is basically the commit checksum stored in a file -- no other information is kept. -To create a lightweight tag, don't supply any of the `-a`, `-s`, or `-m` options, just provide a tag name: - -[source,console] ----- -$ git tag v1.4-lw -$ git tag -v0.1 -v1.3 -v1.4 -v1.4-lw -v1.5 ----- - -This time, if you run `git show` on the tag, you don't see the extra tag information.(((git commands, show))) -The command just shows the commit: +To create a lightweight tag, Nora simply provides the tag name without any options: -[source,console] +[source,bash] ---- -$ git show v1.4-lw -commit ca82a6dff817ec66f44342007202690a93763949 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Mon Mar 17 21:52:11 2008 -0700 - - Change version number +$ git tag v0.1-concept-lw ---- ==== Tagging Later +tag::procedure[] -You can also tag commits after you've moved past them. -Suppose your commit history looks like this: +Nora can also tag commits after she has moved past them. If she realizes she should have tagged the project at the "Initialize" commit, she can find that commit's hash in the log and tag it: -[source,console] ----- -$ git log --pretty=oneline -15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment' -a6b4c97498bd301d84096da251c98a07c7723e65 Create write support -0d52aaab4479697da7686c15f77a3d64d9165190 One more thing -6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment' -0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc Add commit function -4682c3261057305bdd616e23b64b0857d832627b Add todo file -166ae0c4d3f420721acbb115cc33848dfcc2121a Create write support -9fceb02d0ae598e95dc970b74767f19372d61af8 Update rakefile -964f16d36dfccde844893cac5b347e7b3d44abbc Commit the todo -8a5cbc430f1a9c3d00faaeffd07798508422908a Update readme +[source,bash] ---- +$ git log --oneline +ca82a6d [Research: Product] Add vision +085bb3b [Research: Setup] Initialize project -Now, suppose you forgot to tag the project at v1.2, which was at the "`Update rakefile`" commit. -You can add it after the fact. -To tag that commit, you specify the commit checksum (or part of it) at the end of the command: - -[source,console] ----- -$ git tag -a v1.2 9fceb02 +$ git tag -a v0.0-start 085bb3b ---- -You can see that you've tagged the commit:(((git commands, tag))) - -[source,console] ----- -$ git tag -v0.1 -v1.2 -v1.3 -v1.4 -v1.4-lw -v1.5 - -$ git show v1.2 -tag v1.2 -Tagger: Scott Chacon <schacon@gee-mail.com> -Date: Mon Feb 9 15:32:16 2009 -0800 - -version 1.2 -commit 9fceb02d0ae598e95dc970b74767f19372d61af8 -Author: Magnus Chacon <mchacon@gee-mail.com> -Date: Sun Apr 27 20:43:35 2008 -0700 - - Update rakefile -... ----- - -[[_sharing_tags]] ==== Sharing Tags +tag::procedure[] -By default, the `git push` command doesn't transfer tags to remote servers.(((git commands, push))) -You will have to explicitly push tags to a shared server after you have created them. -This process is just like sharing remote branches -- you can run `git push origin <tagname>`. +By default, `git push` doesn’t transfer tags to remote servers. Nora will have to explicitly push tags to a shared server: -[source,console] +[source,bash] ---- -$ git push origin v1.5 -Counting objects: 14, done. -Delta compression using up to 8 threads. -Compressing objects: 100% (12/12), done. -Writing objects: 100% (14/14), 2.05 KiB | 0 bytes/s, done. -Total 14 (delta 3), reused 0 (delta 0) -To git@github.com:schacon/simplegit.git - * [new tag] v1.5 -> v1.5 +$ git push origin v0.1-concept ---- -If you have a lot of tags that you want to push up at once, you can also use the `--tags` option to the `git push` command. -This will transfer all of your tags to the remote server that are not already there. +If she has many tags, she can push them all at once: -[source,console] +[source,bash] ---- $ git push origin --tags -Counting objects: 1, done. -Writing objects: 100% (1/1), 160 bytes | 0 bytes/s, done. -Total 1 (delta 0), reused 0 (delta 0) -To git@github.com:schacon/simplegit.git - * [new tag] v1.4 -> v1.4 - * [new tag] v1.4-lw -> v1.4-lw ---- -Now, when someone else clones or pulls from your repository, they will get all your tags as well. - -[NOTE] -.`git push` pushes both types of tags -==== -`git push <remote> --tags` will push both lightweight and annotated tags. -There is currently no option to push only lightweight tags, but if you use `git push <remote> --follow-tags` only annotated tags will be pushed to the remote. -==== - -==== Deleting Tags +==== Deleting and Checking out Tags +tag::reference[] -To delete a tag on your local repository, you can use `git tag -d <tagname>`. -For example, we could remove our lightweight tag above as follows: +To delete a tag locally: -[source,console] +[source,bash] ---- -$ git tag -d v1.4-lw -Deleted tag 'v1.4-lw' (was e7d5add) +$ git tag -d v0.1-concept ---- -Note that this does not remove the tag from any remote servers. -There are two common variations for deleting a tag from a remote server. +To delete a tag from the server: -The first variation is `git push <remote> :refs/tags/<tagname>`: - -[source,console] +[source,bash] ---- -$ git push origin :refs/tags/v1.4-lw -To /git@github.com:schacon/simplegit.git - - [deleted] v1.4-lw +$ git push origin --delete v0.1-concept ---- -The way to interpret the above is to read it as the null value before the colon is being pushed to the remote tag name, effectively deleting it. - -The second (and more intuitive) way to delete a remote tag is with: +If you want to view the versions of files a tag is pointing to, you can do a `git checkout` of that tag. However, this puts your repository in a "detached HEAD" state, which is fine for looking around but risky for making changes. If you need to fix something on an old tag, it’s best to create a new branch from it: -[source,console] ----- -$ git push origin --delete <tagname> +[source,bash] ---- - -==== Checking out Tags - -If you want to view the versions of files a tag is pointing to, you can do a `git checkout` of that tag, although this puts your repository in "`detached HEAD`" state, which has some ill side effects: - -[source,console] +$ git checkout -b fix/concept-v0.1 v0.1-concept ---- -$ git checkout v2.0.0 -Note: switching to 'v2.0.0'. - -You are in 'detached HEAD' state. You can look around, make experimental -changes and commit them, and you can discard any commits you make in this -state without impacting any branches by performing another checkout. - -If you want to create a new branch to retain commits you create, you may -do so (now or later) by using -c with the switch command. Example: - - git switch -c <new-branch-name> - -Or undo this operation with: - - git switch - - -Turn off this advice by setting config variable advice.detachedHead to false - -HEAD is now at 99ada87... Merge pull request #89 from schacon/appendix-final - -$ git checkout v2.0-beta-0.1 -Previous HEAD position was 99ada87... Merge pull request #89 from schacon/appendix-final -HEAD is now at df3f601... Add atlas.json and cover image ----- - -In "`detached HEAD`" state, if you make changes and then create a commit, the tag will stay the same, but your new commit won't belong to any branch and will be unreachable, except by the exact commit hash. -Thus, if you need to make changes -- say you're fixing a bug on an older version, for instance -- you will generally want to create a branch: - -[source,console] ----- -$ git checkout -b version2 v2.0.0 -Switched to a new branch 'version2' ----- - -If you do this and make a commit, your `version2` branch will be slightly different than your `v2.0.0` tag since it will move forward with your new changes, so do be careful. diff --git a/book/02-git-basics/sections/undoing.asc b/book/02-git-basics/sections/undoing.asc index 0c815dde8..484a8acd5 100644 --- a/book/02-git-basics/sections/undoing.asc +++ b/book/02-git-basics/sections/undoing.asc @@ -1,235 +1,95 @@ -[[_undoing]] === Undoing Things +tag::concept[] -At any stage, you may want to undo something. -Here, we'll review a few basic tools for undoing changes that you've made. -Be careful, because you can't always undo some of these undos. -This is one of the few areas in Git where you may lose some work if you do it wrong. +At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing changes that you’ve made. Be careful, because you can’t always undo some of these undos. This is one of the few areas in Git where you may lose some work if you do it wrong. -One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. -If you want to redo that commit, make the additional changes you forgot, stage them, and commit again using the `--amend` option: +==== Amending a Commit +tag::procedure[] -[source,console] +(((git commands, commit))) +One of the most common undos happens when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to redo that commit, you can make the additional changes you forgot, stage them, and commit again using the `--amend` option: + +[source,bash] ---- $ git commit --amend ---- -This command takes your staging area and uses it for the commit. -If you've made no changes since your last commit (for instance, you run this command immediately after your previous commit), then your snapshot will look exactly the same, and all you'll change is your commit message. - -The same commit-message editor fires up, but it already contains the message of your previous commit. -You can edit the message the same as always, but it overwrites your previous commit. - -As an example, if you commit and then realize you forgot to stage the changes in a file you wanted to add to this commit, you can do something like this: +For example, if Nora commits her product brief but then realizes she forgot to stage her competitive analysis, she can do this: -[source,console] +[source,bash] ---- -$ git commit -m 'Initial commit' -$ git add forgotten_file +$ git commit -m "[Research: Product] Add vision" +$ git add research/competitive-analysis.md $ git commit --amend ---- -You end up with a single commit -- the second commit replaces the results of the first. - -[NOTE] -==== -It's important to understand that when you're amending your last commit, you're not so much fixing it as _replacing_ it entirely with a new, improved commit that pushes the old commit out of the way and puts the new commit in its place. -Effectively, it's as if the previous commit never happened, and it won't show up in your repository history. +You end up with a single commit—the second commit replaces the results of the first. It’s as if the previous commit never happened, and it won’t show up in your repository history. This is great for fixing typos or minor omissions without cluttering the project's timeline with "Oops" commits. -The obvious value to amending commits is to make minor improvements to your last commit, without cluttering your repository history with commit messages of the form, "`Oops, forgot to add a file`" or "`Darn, fixing a typo in last commit`". -==== - -[NOTE] -==== -Only amend commits that are still local and have not been pushed somewhere. -Amending previously pushed commits and force pushing the branch will cause problems for your collaborators. -For more on what happens when you do this and how to recover if you're on the receiving end read <<_rebase_peril>>. -==== - -[[_unstaging]] ==== Unstaging a Staged File +tag::procedure[] + +(((git commands, restore))) +Suppose Nora has changed two files and wants to commit them as two separate checkpoints, but she accidentally types `git add *` and stages them both. How can she unstage one of them? -The next two sections demonstrate how to work with your staging area and working directory changes. -The nice part is that the command you use to determine the state of those two areas also reminds you how to undo changes to them. -For example, let's say you've changed two files and want to commit them as two separate changes, but you accidentally type `git add *` and stage them both. -How can you unstage one of the two? -The `git status` command reminds you: +The `git status` command actually reminds you how to do this: -[source,console] +[source,bash] ---- $ git add * $ git status -On branch master +On branch main Changes to be committed: - (use "git reset HEAD <file>..." to unstage) + (use "git restore --staged <file>..." to unstage) - renamed: README.md -> README - modified: CONTRIBUTING.md + modified: product-brief.md + modified: research/personas/early-adopter.md ---- -Right below the "`Changes to be committed`" text, it says use `git reset HEAD <file>...` to unstage. -So, let's use that advice to unstage the `CONTRIBUTING.md` file: +Right below the "Changes to be committed" text, it says use `git restore --staged <file>...` to unstage. Let’s use that to unstage the persona document: -[source,console] +[source,bash] ---- -$ git reset HEAD CONTRIBUTING.md -Unstaged changes after reset: -M CONTRIBUTING.md +$ git restore --staged research/personas/early-adopter.md $ git status -On branch master +On branch main Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - renamed: README.md -> README + modified: product-brief.md Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: CONTRIBUTING.md + modified: research/personas/early-adopter.md ---- -The command is a bit strange, but it works. -The `CONTRIBUTING.md` file is modified but once again unstaged. - -[NOTE] -===== -It's true that `git reset` can be a dangerous command, especially if you provide the `--hard` flag. -However, in the scenario described above, the file in your working directory is not touched, so it's relatively safe. -===== - -For now this magic invocation is all you need to know about the `git reset` command. -We'll go into much more detail about what `reset` does and how to master it to do really interesting things in <<ch07-git-tools#_git_reset>>. +The file is now modified but once again unstaged. ==== Unmodifying a Modified File +tag::procedure[] -What if you realize that you don't want to keep your changes to the `CONTRIBUTING.md` file? -How can you easily unmodify it -- revert it back to what it looked like when you last committed (or initially cloned, or however you got it into your working directory)? -Luckily, `git status` tells you how to do that, too. -In the last example output, the unstaged area looks like this: - -[source,console] ----- -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: CONTRIBUTING.md ----- - -It tells you pretty explicitly how to discard the changes you've made. -Let's do what it says: - -[source,console] ----- -$ git checkout -- CONTRIBUTING.md -$ git status -On branch master -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - renamed: README.md -> README - ----- - -You can see that the changes have been reverted. - -[IMPORTANT] -===== -It's important to understand that `git checkout \-- <file>` is a dangerous command. -Any local changes you made to that file are gone -- Git just replaced that file with the last staged or committed version. -Don't ever use this command unless you absolutely know that you don't want those unsaved local changes. -===== - -If you would like to keep the changes you've made to that file but still need to get it out of the way for now, we'll go over stashing and branching in <<ch03-git-branching#ch03-git-branching>>; these are generally better ways to go. - -Remember, anything that is _committed_ in Git can almost always be recovered. -Even commits that were on branches that were deleted or commits that were overwritten with an `--amend` commit can be recovered (see <<ch10-git-internals#_data_recovery>> for data recovery). -However, anything you lose that was never committed is likely never to be seen again. - -[[undoing_git_restore]] -==== Undoing things with git restore - -Git version 2.23.0 introduced a new command: `git restore`. -It's basically an alternative to `git reset` which we just covered. -From Git version 2.23.0 onwards, Git will use `git restore` instead of `git reset` for many undo operations. - -Let's retrace our steps, and undo things with `git restore` instead of `git reset`. +What if Nora realizes that she doesn't want to keep the changes she made to `product-brief.md`? How can she easily revert it back to what it looked like when she last committed? -===== Unstaging a Staged File with git restore +Again, `git status` gives the answer: -The next two sections demonstrate how to work with your staging area and working directory changes with `git restore`. -The nice part is that the command you use to determine the state of those two areas also reminds you how to undo changes to them. -For example, let's say you've changed two files and want to commit them as two separate changes, but you accidentally type `git add *` and stage them both. -How can you unstage one of the two? -The `git status` command reminds you: - -[source,console] +[source,bash] ---- -$ git add * $ git status -On branch master -Changes to be committed: - (use "git restore --staged <file>..." to unstage) - modified: CONTRIBUTING.md - renamed: README.md -> README - ----- - -Right below the "`Changes to be committed`" text, it says use `git restore --staged <file>...` to unstage. -So, let's use that advice to unstage the `CONTRIBUTING.md` file: - -[source,console] ----- -$ git restore --staged CONTRIBUTING.md -$ git status -On branch master -Changes to be committed: - (use "git restore --staged <file>..." to unstage) - renamed: README.md -> README - Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) - modified: CONTRIBUTING.md + modified: product-brief.md ---- -The `CONTRIBUTING.md` file is modified but once again unstaged. - -===== Unmodifying a Modified File with git restore - -What if you realize that you don't want to keep your changes to the `CONTRIBUTING.md` file? -How can you easily unmodify it -- revert it back to what it looked like when you last committed (or initially cloned, or however you got it into your working directory)? -Luckily, `git status` tells you how to do that, too. -In the last example output, the unstaged area looks like this: +It tells her explicitly how to discard the changes. Let's do what it says: -[source,console] +[source,bash] ---- -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git restore <file>..." to discard changes in working directory) - modified: CONTRIBUTING.md - ----- - -It tells you pretty explicitly how to discard the changes you've made. -Let's do what it says: - -[source,console] ----- -$ git restore CONTRIBUTING.md +$ git restore product-brief.md $ git status -On branch master -Changes to be committed: - (use "git restore --staged <file>..." to unstage) - renamed: README.md -> README - +nothing to commit, working tree clean ---- [IMPORTANT] -===== -It's important to understand that `git restore <file>` is a dangerous command. -Any local changes you made to that file are gone -- Git just replaced that file with the last staged or committed version. -Don't ever use this command unless you absolutely know that you don't want those unsaved local changes. -===== +==== +It’s important to understand that `git restore <file>` is a dangerous command. Any local changes you made to that file are gone—Git just replaced that file with the last committed version. **Don’t ever use this command unless you absolutely know that you don’t want those unsaved local changes.** +==== + +If you want to keep the changes but get them out of the way for now, we'll cover "stashing" and "branching" in <<ch03-git-branching#ch03-git-branching>>; these are generally much safer ways to handle temporary work. diff --git a/book/02-git-basics/sections/viewing-history.asc b/book/02-git-basics/sections/viewing-history.asc index 440c7f250..183901900 100644 --- a/book/02-git-basics/sections/viewing-history.asc +++ b/book/02-git-basics/sections/viewing-history.asc @@ -1,306 +1,108 @@ -[[_viewing_history]] === Viewing the Commit History +tag::concept[] -After you have created several commits, or if you have cloned a repository with an existing commit history, you'll probably want to look back to see what has happened. -The most basic and powerful tool to do this is the `git log` command. +(((git commands, log))) +After Nora has created several checkpoints, she’ll probably want to look back to see what has happened. The most basic and powerful tool for this is the `git log` command. -These examples use a very simple project called "`simplegit`". -To get the project, run: +If Nora runs `git log` in her SketchSpark repository, she sees her commits in reverse chronological order: -[source,console] ----- -$ git clone https://github.com/schacon/simplegit-progit ----- - -When you run `git log` in this project, you should get output that looks something like this:(((git commands, log))) - -[source,console] +[source,bash] ---- $ git log commit ca82a6dff817ec66f44342007202690a93763949 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Mon Mar 17 21:52:11 2008 -0700 +Author: Nora UX <nora@sketchspark.io> +Date: Mon Mar 17 21:52:11 2026 -0700 - Change version number + [Research: Product] Add initial vision and core features -commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Sat Mar 15 16:40:33 2008 -0700 +commit 085bb3bcb870472738ea7930af94390bbdd91b23 +Author: Nora UX <nora@sketchspark.io> +Date: Sun Mar 16 15:10:05 2026 -0700 - Remove unnecessary test - -commit a11bef06a3f659402fe7563abf99ad00de2209e6 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Sat Mar 15 10:31:28 2008 -0700 - - Initial commit + [Research: Setup] Initialize project and add .gitignore ---- -By default, with no arguments, `git log` lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first. -As you can see, this command lists each commit with its SHA-1 checksum, the author's name and email, the date written, and the commit message. +By default, `git log` lists the SHA-1 checksum, the author's name and email, the date, and the commit message. -A huge number and variety of options to the `git log` command are available to show you exactly what you're looking for. -Here, we'll show you some of the most popular. +==== Viewing Changes with Patch Output +tag::reference[] -One of the more helpful options is `-p` or `--patch`, which shows the difference (the _patch_ output) introduced in each commit. -You can also limit the number of log entries displayed, such as using `-2` to show only the last two entries. +If Nora wants to see exactly what changed in each commit, she can use the `-p` or `--patch` flag. This shows the "diff" introduced in each commit: -[source,console] +[source,bash] ---- $ git log -p -2 -commit ca82a6dff817ec66f44342007202690a93763949 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Mon Mar 17 21:52:11 2008 -0700 - - Change version number - -diff --git a/Rakefile b/Rakefile -index a874b73..8f94139 100644 ---- a/Rakefile -+++ b/Rakefile -@@ -5,7 +5,7 @@ require 'rake/gempackagetask' - spec = Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = "simplegit" -- s.version = "0.1.0" -+ s.version = "0.1.1" - s.author = "Scott Chacon" - s.email = "schacon@gee-mail.com" - s.summary = "A simple gem for using Git in Ruby code." - -commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Sat Mar 15 16:40:33 2008 -0700 - - Remove unnecessary test - -diff --git a/lib/simplegit.rb b/lib/simplegit.rb -index a0a60ae..47c6340 100644 ---- a/lib/simplegit.rb -+++ b/lib/simplegit.rb -@@ -18,8 +18,3 @@ class SimpleGit - end - - end -- --if $0 == __FILE__ -- git = SimpleGit.new -- puts git.show --end ----- - -This option displays the same information but with a diff directly following each entry. -This is very helpful for code review or to quickly browse what happened during a series of commits that a collaborator has added. -You can also use a series of summarizing options with `git log`. -For example, if you want to see some abbreviated stats for each commit, you can use the `--stat` option: - -[source,console] ---- -$ git log --stat -commit ca82a6dff817ec66f44342007202690a93763949 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Mon Mar 17 21:52:11 2008 -0700 - - Change version number - - Rakefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Sat Mar 15 16:40:33 2008 -0700 - - Remove unnecessary test - lib/simplegit.rb | 5 ----- - 1 file changed, 5 deletions(-) +The `-2` limits the output to only the last two entries. This is incredibly useful for reviewing research notes or seeing how a persona evolved. -commit a11bef06a3f659402fe7563abf99ad00de2209e6 -Author: Scott Chacon <schacon@gee-mail.com> -Date: Sat Mar 15 10:31:28 2008 -0700 +==== Viewing Abbreviated Stats +tag::reference[] - Initial commit +If Nora wants to see which files were affected without the full line-by-line diff, she can use `--stat`: - README | 6 ++++++ - Rakefile | 23 +++++++++++++++++++++++ - lib/simplegit.rb | 25 +++++++++++++++++++++++++ - 3 files changed, 54 insertions(+) +[source,bash] +---- +$ git log --stat ---- -As you can see, the `--stat` option prints below each commit entry a list of modified files, how many files were changed, and how many lines in those files were added and removed. -It also puts a summary of the information at the end. +This shows which files changed, how many lines were added or removed in each, and a summary. For design projects, this helps Nora quickly see if a commit was about text (`product-brief.md`) or visual assets (`concept/wireframes/`). -Another really useful option is `--pretty`. -This option changes the log output to formats other than the default. -A few prebuilt option values are available for you to use. -The `oneline` value for this option prints each commit on a single line, which is useful if you're looking at a lot of commits. -In addition, the `short`, `full`, and `fuller` values show the output in roughly the same format but with less or more information, respectively: +==== Formatting the Log +tag::reference[] -[source,console] +One of the most useful options is `--pretty`, which changes the log output to formats other than the default. The `oneline` option is especially handy for a quick overview: + +[source,bash] ---- $ git log --pretty=oneline -ca82a6dff817ec66f44342007202690a93763949 Change version number -085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 Remove unnecessary test -a11bef06a3f659402fe7563abf99ad00de2209e6 Initial commit +ca82a6dff817ec66f44342007202690a93763949 [Research: Product] Add initial vision and core features +085bb3bcb870472738ea7930af94390bbdd91b23 [Research: Setup] Initialize project and add .gitignore ---- -The most interesting option value is `format`, which allows you to specify your own log output format. -This is especially useful when you're generating output for machine parsing -- because you specify the format explicitly, you know it won't change with updates to Git:(((log formatting))) +The `format` option allows you to specify your own log output format. This is useful when you're generating reports for stakeholders: -[source,console] +[source,bash] ---- $ git log --pretty=format:"%h - %an, %ar : %s" -ca82a6d - Scott Chacon, 6 years ago : Change version number -085bb3b - Scott Chacon, 6 years ago : Remove unnecessary test -a11bef0 - Scott Chacon, 6 years ago : Initial commit ----- - -<<pretty_format>> lists some of the more useful specifiers that `format` takes. - -[[pretty_format]] -.Useful specifiers for `git log --pretty=format` -[cols="1,4",options="header"] -|================================ -| Specifier | Description of Output -| `%H` | Commit hash -| `%h` | Abbreviated commit hash -| `%T` | Tree hash -| `%t` | Abbreviated tree hash -| `%P` | Parent hashes -| `%p` | Abbreviated parent hashes -| `%an` | Author name -| `%ae` | Author email -| `%ad` | Author date (format respects the `--date=option`) -| `%ar` | Author date, relative -| `%cn` | Committer name -| `%ce` | Committer email -| `%cd` | Committer date -| `%cr` | Committer date, relative -| `%s` | Subject -|================================ - -You may be wondering what the difference is between _author_ and _committer_. -The author is the person who originally wrote the work, whereas the committer is the person who last applied the work. -So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit -- you as the author, and the core member as the committer. -We'll cover this distinction a bit more in <<ch05-distributed-git#ch05-distributed-git>>. - -The `oneline` and `format` option values are particularly useful with another `log` option called `--graph`. -This option adds a nice little ASCII graph showing your branch and merge history: - -[source,console] ----- -$ git log --pretty=format:"%h %s" --graph -* 2d3acf9 Ignore errors from SIGCHLD on trap -* 5e3ee11 Merge branch 'master' of https://github.com/dustin/grit.git -|\ -| * 420eac9 Add method for getting the current branch -* | 30e367c Timeout code and tests -* | 5a09431 Add timeout protection to grit -* | e1193f8 Support for heads with slashes in them -|/ -* d6016bc Require time for xmlschema -* 11d191e Merge branch 'defunkt' into local +ca82a6d - Nora UX, 2 days ago : [Research: Product] Add initial vision... ---- -This type of output will become more interesting as we go through branching and merging in the next chapter. - -Those are only some simple output-formatting options to `git log` -- there are many more. -<<log_options>> lists the options we've covered so far, as well as some other common formatting options that may be useful, along with how they change the output of the `log` command. - -[[log_options]] -.Common options to `git log` -[cols="1,4",options="header"] -|================================ -| Option | Description -| `-p` | Show the patch introduced with each commit. -| `--stat` | Show statistics for files modified in each commit. -| `--shortstat` | Display only the changed/insertions/deletions line from the `--stat` command. -| `--name-only` | Show the list of files modified after the commit information. -| `--name-status` | Show the list of files affected with added/modified/deleted information as well. -| `--abbrev-commit` | Show only the first few characters of the SHA-1 checksum instead of all 40. -| `--relative-date` | Display the date in a relative format (for example, "`2 weeks ago`") instead of using the full date format. -| `--graph` | Display an ASCII graph of the branch and merge history beside the log output. -| `--pretty` | Show commits in an alternate format. Option values include `oneline`, `short`, `full`, `fuller`, and `format` (where you specify your own format). -| `--oneline` | Shorthand for `--pretty=oneline --abbrev-commit` used together. -|================================ - -==== Limiting Log Output +==== Visualizing with Graphs +tag::reference[] -In addition to output-formatting options, `git log` takes a number of useful limiting options; that is, options that let you show only a subset of commits. -You've seen one such option already -- the `-2` option, which displays only the last two commits. -In fact, you can do `-<n>`, where `n` is any integer to show the last `n` commits. -In reality, you're unlikely to use that often, because Git by default pipes all output through a pager so you see only one page of log output at a time. +As Nora's team grows and Sam starts branching, the `--graph` option will become essential. It adds a nice little ASCII graph showing your branch and merge history: -However, the time-limiting options such as `--since` and `--until` are very useful. -For example, this command gets the list of commits made in the last two weeks: - -[source,console] +[source,bash] ---- -$ git log --since=2.weeks +$ git log --oneline --graph --all ---- -This command works with lots of formats -- you can specify a specific date like `"2008-01-15"`, or a relative date such as `"2 years 1 day 3 minutes ago"`. +==== Limiting Log Output +tag::reference[] -You can also filter the list to commits that match some search criteria. -The `--author` option allows you to filter on a specific author, and the `--grep` option lets you search for keywords in the commit messages. +Nora can limit the log output based on time, author, or even specific keywords in the commit message. -[NOTE] -==== -You can specify more than one instance of both the `--author` and `--grep` search criteria, which will limit the commit output to commits that match _any_ of the `--author` patterns and _any_ of the `--grep` patterns; however, adding the `--all-match` option further limits the output to just those commits that match _all_ `--grep` patterns. -==== +* `--since="2026-03-15"`: Show commits after a specific date. +* `--author="Nora"`: Show commits only by Nora. +* `--grep="Competitors"`: Show commits whose messages contain the word "Competitors." -Another really helpful filter is the `-S` option (colloquially referred to as Git's "`pickaxe`" option), which takes a string and shows only those commits that changed the number of occurrences of that string. -For instance, if you wanted to find the last commit that added or removed a reference to a specific function, you could call: +==== Searching for a Specific Design Decision +tag::procedure[] -[source,console] ----- -$ git log -S function_name ----- +(((git commands, log))) +One of Nora's favorite features is the `-S` flag (the "pickaxe" option). It searches for commits that added or removed a specific string of text. -The last really useful option to pass to `git log` as a filter is a path. -If you specify a directory or file name, you can limit the log output to commits that introduced a change to those files. -This is always the last option and is generally preceded by double dashes (`--`) to separate the paths from the options: +Earlier, Nora changed the product brief from "3 options" to "5 options." To find when that decision was made, she runs: -[source,console] ----- -$ git log -- path/to/file +[source,bash] ---- +$ git log -S "5 options" +commit 4b5e6f... +Author: Nora UX <nora@sketchspark.io> +Date: Wed Mar 19 10:15:00 2026 -0700 -In <<limit_options>> we'll list these and a few other common options for your reference. - -[[limit_options]] -.Options to limit the output of `git log` -[cols="2,4",options="header"] -|================================ -| Option | Description -| `-<n>` | Show only the last n commits. -| `--since`, `--after` | Limit the commits to those made after the specified date. -| `--until`, `--before` | Limit the commits to those made before the specified date. -| `--author` | Only show commits in which the author entry matches the specified string. -| `--committer` | Only show commits in which the committer entry matches the specified string. -| `--grep` | Only show commits with a commit message containing the string. -| `-S` | Only show commits adding or removing code matching the string. -|================================ - -For example, if you want to see which commits modifying test files in the Git source code history were committed by Junio Hamano in the month of October 2008 and are not merge commits, you can run something like this:(((log filtering))) - -[source,console] ----- -$ git log --pretty="%h - %s" --author='Junio C Hamano' --since="2008-10-01" \ - --before="2008-11-01" --no-merges -- t/ -5610e3b - Fix testcase failure when extended attributes are in use -acd3b9e - Enhance hold_lock_file_for_{update,append}() API -f563754 - demonstrate breakage of detached checkout with symbolic link HEAD -d1a43f2 - reset --hard/read-tree --reset -u: remove unmerged new paths -51a94af - Fix "checkout --track -b newbranch" on detached HEAD -b0ad11e - pull: allow "git pull origin $something:$current_branch" into an unborn branch + [Research: Product] Increase parallel UI options from 3 to 5 ---- -Of the nearly 40,000 commits in the Git source code history, this command shows the 6 that match those criteria. - -[TIP] -.Preventing the display of merge commits -==== -Depending on the workflow used in your repository, it's possible that a sizable percentage of the commits in your log history are just merge commits, which typically aren't very informative. -To prevent the display of merge commits cluttering up your log history, simply add the `log` option `--no-merges`. -==== +This allows Nora to trace the history of a **design decision** back to the exact moment it was finalized. Git isn't just a file tracker; it's a ledger of why the project looks the way it does. diff --git a/book/03-git-branching/sections/basic-branching-and-merging.asc b/book/03-git-branching/sections/basic-branching-and-merging.asc index a894b6702..fc3655ff2 100644 --- a/book/03-git-branching/sections/basic-branching-and-merging.asc +++ b/book/03-git-branching/sections/basic-branching-and-merging.asc @@ -1,318 +1,175 @@ === Basic Branching and Merging +tag::walkthrough[] -Let's go through a simple example of branching and merging with a workflow that you might use in the real world. -You'll follow these steps: +Let’s look at a real-world example of branching and merging that Nora and Sam use at SketchSpark. You’ll follow these steps: -. Do some work on a website. -. Create a branch for a new user story you're working on. -. Do some work in that branch. +1. Sam joins the project and creates a branch for a new UI exploration. +2. He does some work in that branch. +3. A critical bug is reported in the current prototype, and Nora needs a hotfix. -At this stage, you'll receive a call that another issue is critical and you need a hotfix. -You'll do the following: +To handle this, they will: -. Switch to your production branch. -. Create a branch to add the hotfix. -. After it's tested, merge the hotfix branch, and push to production. -. Switch back to your original user story and continue working. +1. Switch back to the `main` branch. +2. Create a branch for the hotfix. +3. After testing, merge the hotfix into `main`. +4. Sam switches back to his UI exploration and continues working. [[_basic_branching]] ==== Basic Branching +tag::procedure[] (((branches, basic workflow))) -First, let's say you're working on your project and have a couple of commits already on the `master` branch. +First, let’s say the SketchSpark repo has a few commits already on the `main` branch. Sam is tasked with exploring a new "card-based" layout for the results screen. To create a new branch and switch to it at the same time, he runs: -.A simple commit history -image::images/basic-branching-1.png[A simple commit history] - -You've decided that you're going to work on issue #53 in whatever issue-tracking system your company uses. -To create a new branch and switch to it at the same time, you can run the `git checkout` command with the `-b` switch: - -[source,console] +[source,bash] ---- -$ git checkout -b iss53 -Switched to a new branch "iss53" +$ git checkout -b option/card-layout +Switched to a new branch "option/card-layout" ---- -This is shorthand for: - -[source,console] ----- -$ git branch iss53 -$ git checkout iss53 ----- +This is a shorthand for creating the branch and then checking it out. -.Creating a new branch pointer +.Creating a new branch pointer for Sam's exploration image::images/basic-branching-2.png[Creating a new branch pointer] -You work on your website and do some commits. -Doing so moves the `iss53` branch forward, because you have it checked out (that is, your `HEAD` is pointing to it): +Sam works on the card layout, updating the Figma source and exporting a new preview PNG. He commits his work: -[source,console] +[source,bash] ---- -$ vim index.html -$ git commit -a -m 'Create new footer [issue 53]' +$ git commit -a -m "[Design: Results] Add initial grid layout for cards" ---- -.The `iss53` branch has moved forward with your work -image::images/basic-branching-3.png[The `iss53` branch has moved forward with your work] +Now his `option/card-layout` branch has moved forward, but Nora's `main` branch remains stable. -Now you get the call that there is an issue with the website, and you need to fix it immediately. -With Git, you don't have to deploy your fix along with the `iss53` changes you've made, and you don't have to put a lot of effort into reverting those changes before you can work on applying your fix to what is in production. -All you have to do is switch back to your `master` branch. +.The exploration branch moves forward +image::images/basic-branching-3.png[The branch has moved forward with your work] -However, before you do that, note that if your working directory or staging area has uncommitted changes that conflict with the branch you're checking out, Git won't let you switch branches. -It's best to have a clean working state when you switch branches. -There are ways to get around this (namely, stashing and commit amending) that we'll cover later on, in <<ch07-git-tools#_git_stashing>>. -For now, let's assume you've committed all your changes, so you can switch back to your `master` branch: +Suddenly, a user report comes in: the "sketch upload" screen is missing an error state. This is a critical fix needed for the alpha demo. Because Sam is using Git, he doesn't have to throw away his card layout work or "undo" anything. He simply switches back to `main`. -[source,console] +[IMPORTANT] +==== +Before you switch branches, make sure your working directory is clean (all changes committed). If you have uncommitted changes that conflict with the branch you're switching to, Git won't let you switch. We’ll cover how to "stash" unfinished work in <<ch07-git-tools#_git_stashing>>. +==== + +[source,bash] ---- -$ git checkout master -Switched to branch 'master' +$ git checkout main +Switched to branch 'main' ---- -At this point, your project working directory is exactly the way it was before you started working on issue #53, and you can concentrate on your hotfix. -This is an important point to remember: when you switch branches, Git resets your working directory to look like it did the last time you committed on that branch. -It adds, removes, and modifies files automatically to make sure your working copy is what the branch looked like on your last commit to it. +At this point, Sam's project folder looks exactly like it did before he started the card layout. He can now focus on the hotfix. He creates a `fix` branch: -Next, you have a hotfix to make. -Let's create a `hotfix` branch on which to work until it's completed: - -[source,console] +[source,bash] ---- -$ git checkout -b hotfix -Switched to a new branch 'hotfix' -$ vim index.html -$ git commit -a -m 'Fix broken email address' -[hotfix 1fb7853] Fix broken email address - 1 file changed, 2 insertions(+) +$ git checkout -b fix/upload-error-state +$ vim screens/sketch-input/upload-flow.png # Sam updates the UI +$ git commit -a -m "[Fix: Sketch Input] Add missing error state for failed uploads" ---- -.Hotfix branch based on `master` -image::images/basic-branching-4.png[Hotfix branch based on `master`] +.Hotfix branch based on `main` +image::images/basic-branching-4.png[Hotfix branch based on main] -You can run your tests, make sure the hotfix is what you want, and finally merge the `hotfix` branch back into your `master` branch to deploy to production. -You do this with the `git merge` command:(((git commands, merge))) +Once the fix is verified, Nora merges it into the `main` branch to deploy it: -[source,console] +[source,bash] ---- -$ git checkout master -$ git merge hotfix +$ git checkout main +$ git merge fix/upload-error-state Updating f42c576..3a0874c Fast-forward - index.html | 2 ++ - 1 file changed, 2 insertions(+) + screens/sketch-input/upload-flow.png | Bin 45210 -> 46890 bytes + 1 file changed, 0 insertions(+), 0 deletions(-) ---- -You'll notice the phrase "`fast-forward`" in that merge. -Because the commit `C4` pointed to by the branch `hotfix` you merged in was directly ahead of the commit `C2` you're on, Git simply moves the pointer forward. -To phrase that another way, when you try to merge one commit with a commit that can be reached by following the first commit's history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together -- this is called a "`fast-forward.`" - -Your change is now in the snapshot of the commit pointed to by the `master` branch, and you can deploy the fix. +You’ll notice the phrase **"fast-forward"**. Because the `fix/upload-error-state` branch was directly ahead of `main`, Git simply moved the `main` pointer forward. -.`master` is fast-forwarded to `hotfix` -image::images/basic-branching-5.png[`master` is fast-forwarded to `hotfix`] +Now the fix is in the "truth" of the project, and Nora can delete the temporary fix branch: -After your super-important fix is deployed, you're ready to switch back to the work you were doing before you were interrupted. -However, first you'll delete the `hotfix` branch, because you no longer need it -- the `master` branch points at the same place. -You can delete it with the `-d` option to `git branch`: - -[source,console] +[source,bash] ---- -$ git branch -d hotfix -Deleted branch hotfix (3a0874c). +$ git branch -d fix/upload-error-state ---- -Now you can switch back to your work-in-progress branch on issue #53 and continue working on it. +Sam is now free to switch back to his card layout exploration: -[source,console] +[source,bash] ---- -$ git checkout iss53 -Switched to branch "iss53" -$ vim index.html -$ git commit -a -m 'Finish the new footer [issue 53]' -[iss53 ad82d7a] Finish the new footer [issue 53] -1 file changed, 1 insertion(+) +$ git checkout option/card-layout ---- -.Work continues on `iss53` -image::images/basic-branching-6.png[Work continues on `iss53`] - -It's worth noting here that the work you did in your `hotfix` branch is not contained in the files in your `iss53` branch. -If you need to pull it in, you can merge your `master` branch into your `iss53` branch by running `git merge master`, or you can wait to integrate those changes until you decide to pull the `iss53` branch back into `master` later. - -[[_basic_merging]] ==== Basic Merging +tag::procedure[] (((branches, merging)))(((merging))) -Suppose you've decided that your issue #53 work is complete and ready to be merged into your `master` branch. -In order to do that, you'll merge your `iss53` branch into `master`, much like you merged your `hotfix` branch earlier. -All you have to do is check out the branch you wish to merge into and then run the `git merge` command: +A few days later, the card layout is approved. Nora wants to integrate it into the main project. She switches to `main` and merges Sam's work: -[source,console] +[source,bash] ---- -$ git checkout master -Switched to branch 'master' -$ git merge iss53 +$ git checkout main +$ git merge option/card-layout Merge made by the 'recursive' strategy. -index.html | 1 + -1 file changed, 1 insertion(+) + screens/results/card-layout.png | Bin 0 -> 125430 bytes + 1 file changed, 0 insertions(+), 0 deletions(-) ---- -This looks a bit different than the `hotfix` merge you did earlier. -In this case, your development history has diverged from some older point. -Because the commit on the branch you're on isn't a direct ancestor of the branch you're merging in, Git has to do some work. -In this case, Git does a simple three-way merge, using the two snapshots pointed to by the branch tips and the common ancestor of the two. - -.Three snapshots used in a typical merge -image::images/basic-merging-1.png[Three snapshots used in a typical merge] - -Instead of just moving the branch pointer forward, Git creates a new snapshot that results from this three-way merge and automatically creates a new commit that points to it. -This is referred to as a merge commit, and is special in that it has more than one parent. +This merge looks different. Because the history had diverged (Nora might have made other small research updates on `main` while Sam was working), Git performs a **three-way merge**. It uses the two branch tips and their common ancestor to create a new "merge commit." -.A merge commit +.A merge commit integrating divergent work image::images/basic-merging-2.png[A merge commit] -Now that your work is merged in, you have no further need for the `iss53` branch. -You can close the issue in your issue-tracking system, and delete the branch: - -[source,console] ----- -$ git branch -d iss53 ----- - -[[_basic_merge_conflicts]] ==== Basic Merge Conflicts +tag::procedure[] (((merging, conflicts))) -Occasionally, this process doesn't go smoothly. -If you changed the same part of the same file differently in the two branches you're merging, Git won't be able to merge them cleanly. -If your fix for issue #53 modified the same part of a file as the `hotfix` branch, you'll get a merge conflict that looks something like this: +Occasionally, the process doesn’t go smoothly. If Nora and Sam both edited the same line of the same file—for example, the `user-flows.md` file—Git won't be able to merge them automatically. This is a **merge conflict**. -[source,console] +[source,bash] ---- -$ git merge iss53 -Auto-merging index.html -CONFLICT (content): Merge conflict in index.html +$ git merge option/card-layout +Auto-merging concept/user-flows.md +CONFLICT (content): Merge conflict in concept/user-flows.md Automatic merge failed; fix conflicts and then commit the result. ---- -Git hasn't automatically created a new merge commit. -It has paused the process while you resolve the conflict. -If you want to see which files are unmerged at any point after a merge conflict, you can run `git status`: +Git pauses and asks Nora to resolve the mess. If she runs `git status`, she can see which files are "unmerged": -[source,console] +[source,bash] ---- $ git status -On branch master +On branch main You have unmerged paths. - (fix conflicts and run "git commit") - Unmerged paths: - (use "git add <file>..." to mark resolution) - - both modified: index.html - -no changes added to commit (use "git add" and/or "git commit -a") + both modified: concept/user-flows.md ---- -Anything that has merge conflicts and hasn't been resolved is listed as unmerged. -Git adds standard conflict-resolution markers to the files that have conflicts, so you can open them manually and resolve those conflicts. -Your file contains a section that looks something like this: +Inside the file, Git adds markers to show the conflicting versions: -[source,html] +[source,markdown] ---- -<<<<<<< HEAD:index.html -<div id="footer">contact : email.support@github.com</div> +<<<<<<< HEAD:concept/user-flows.md +1. User uploads sketch +2. System validates input ======= -<div id="footer"> - please contact us at support@github.com -</div> ->>>>>>> iss53:index.html ----- - -This means the version in `HEAD` (your `master` branch, because that was what you had checked out when you ran your merge command) is the top part of that block (everything above the `=======`), while the version in your `iss53` branch looks like everything in the bottom part. -In order to resolve the conflict, you have to either choose one side or the other or merge the contents yourself. -For instance, you might resolve this conflict by replacing the entire block with this: - -[source,html] ----- -<div id="footer"> -please contact us at email.support@github.com -</div> +1. User uploads sketch +2. User chooses "Card Layout" vs "List Layout" +>>>>>>> option/card-layout:concept/user-flows.md ---- -This resolution has a little of each section, and the `<<<<<<<`, `=======`, and `>>>>>>>` lines have been completely removed. -After you've resolved each of these sections in each conflicted file, run `git add` on each file to mark it as resolved. -Staging the file marks it as resolved in Git. - -If you want to use a graphical tool to resolve these issues, you can run `git mergetool`, which fires up an appropriate visual merge tool and walks you through the conflicts:(((git commands, mergetool))) +The top part (above the `=======`) is what was on `main` (Nora's version). The bottom part is Sam's version. To resolve it, Nora must edit the file to look the way she wants it—perhaps combining both ideas—and remove the markers: -[source,console] +[source,markdown] ---- -$ git mergetool - -This message is displayed because 'merge.tool' is not configured. -See 'git mergetool --tool-help' or 'git help config' for more details. -'git mergetool' will now attempt to use one of the following tools: -opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge ecmerge p4merge araxis bc3 codecompare vimdiff emerge -Merging: -index.html - -Normal merge conflict for 'index.html': - {local}: modified file - {remote}: modified file -Hit return to start merge resolution tool (opendiff): ----- - -If you want to use a merge tool other than the default (Git chose `opendiff` in this case because the command was run on macOS), you can see all the supported tools listed at the top after "`one of the following tools.`" -Just type the name of the tool you'd rather use. - -[NOTE] -==== -If you need more advanced tools for resolving tricky merge conflicts, we cover more on merging in <<ch07-git-tools#_advanced_merging>>. -==== - -After you exit the merge tool, Git asks you if the merge was successful. -If you tell the script that it was, it stages the file to mark it as resolved for you. -You can run `git status` again to verify that all conflicts have been resolved: - -[source,console] ----- -$ git status -On branch master -All conflicts fixed but you are still merging. - (use "git commit" to conclude merge) - -Changes to be committed: - - modified: index.html +1. User uploads sketch +2. System validates input +3. User chooses "Card Layout" vs "List Layout" ---- -If you're happy with that, and you verify that everything that had conflicts has been staged, you can type `git commit` to finalize the merge commit. -The commit message by default looks something like this: +Once she's fixed the file, she stages it to mark it as resolved: -[source,console] +[source,bash] ---- -Merge branch 'iss53' - -Conflicts: - index.html -# -# It looks like you may be committing a merge. -# If this is not correct, please remove the file -# .git/MERGE_HEAD -# and try again. - - -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit. -# On branch master -# All conflicts fixed but you are still merging. -# -# Changes to be committed: -# modified: index.html -# +$ git add concept/user-flows.md +$ git commit ---- -If you think it would be helpful to others looking at this merge in the future, you can modify this commit message with details about how you resolved the merge and explain why you did the changes you made if these are not obvious. +The merge is complete. Nora and Sam have reconciled their divergent ideas into a single, unified project history. diff --git a/book/03-git-branching/sections/branch-management.asc b/book/03-git-branching/sections/branch-management.asc index ae81e89aa..3d434c24a 100644 --- a/book/03-git-branching/sections/branch-management.asc +++ b/book/03-git-branching/sections/branch-management.asc @@ -1,183 +1,95 @@ -[[_branch_management]] === Branch Management +tag::reference[] -(((branches, managing))) -Now that you've created, merged, and deleted some branches, let's look at some branch-management tools that will come in handy when you begin using branches all the time. +(((branches, management))) +Now that Nora and Sam are creating, switching, and merging branches, Nora needs a way to keep everything organized. The `git branch` command does more than just create branches; it’s also her primary tool for managing them. -The `git branch` command does more than just create and delete branches.(((git commands, branch))) -If you run it with no arguments, you get a simple listing of your current branches: +==== Listing Your Branches +tag::procedure[] -[source,console] ----- -$ git branch - iss53 -* master - testing ----- +If Nora runs `git branch` without any arguments, she gets a simple list of her current branches: -Notice the `*` character that prefixes the `master` branch: it indicates the branch that you currently have checked out (i.e., the branch that `HEAD` points to). -This means that if you commit at this point, the `master` branch will be moved forward with your new work. -To see the last commit on each branch, you can run `git branch -v`: - -[source,console] +[source,bash] ---- -$ git branch -v - iss53 93b412c Fix javascript issue -* master 7a98805 Merge branch 'iss53' - testing 782fd34 Add scott to the author list in the readme +$ git branch +* main + option/card-layout + option/list-layout + option/canvas-freeform ---- -The useful `--merged` and `--no-merged` options can filter this list to branches that you have or have not yet merged into the branch you're currently on. -To see which branches are already merged into the branch you're on, you can run `git branch --merged`: - -[source,console] ----- -$ git branch --merged - iss53 -* master ----- +The asterisk (`*`) indicates the branch Nora currently has checked out (where **HEAD** is pointing). -Because you already merged in `iss53` earlier, you see it in your list. -Branches on this list without the `*` in front of them are generally fine to delete with `git branch -d`; you've already incorporated their work into another branch, so you're not going to lose anything. +==== Viewing Branch Details +tag::procedure[] -To see all the branches that contain work you haven't yet merged in, you can run `git branch --no-merged`: +To see the last checkpoint (commit) on each branch, she can use the `-v` flag: -[source,console] +[source,bash] ---- -$ git branch --no-merged - testing +$ git branch -v +* main f30ab [Research: Product] Add parallel UI goals + option/card-layout 34ac2 [Design: Results] Add initial grid layout + option/list-layout 98ca9 [Design: Results] Prototype vertical stack ---- -This shows your other branch. -Because it contains work that isn't merged in yet, trying to delete it with `git branch -d` will fail: - -[source,console] ----- -$ git branch -d testing -error: The branch 'testing' is not fully merged. -If you are sure you want to delete it, run 'git branch -D testing'. ----- +==== Filtering Merged and Unmerged Branches +tag::procedure[] -If you really do want to delete the branch and lose that work, you can force it with `-D`, as the helpful message points out. +As the SketchSpark repo grows, Nora will want to know which branches have already been integrated into `main` and which are still work-in-progress. -[TIP] -==== -The options described above, `--merged` and `--no-merged` will, if not given a commit or branch name as an argument, show you what is, respectively, merged or not merged into your _current_ branch. +To see which branches she has already merged into her current branch, she runs: -You can always provide an additional argument to ask about the merge state with respect to some other branch without checking that other branch out first, as in, what is not merged into the `master` branch? -[source,console] +[source,bash] ---- -$ git checkout testing -$ git branch --no-merged master - topicA - featureB +$ git branch --merged + option/card-layout +* main ---- -==== - -==== Changing a branch name - -[CAUTION] -==== -Do not rename branches that are still in use by other collaborators. -Do not rename a branch like master/main/mainline without having read the section <<_changing_master>>. -==== -Suppose you have a branch that is called `bad-branch-name` and you want to change it to `corrected-branch-name`, while keeping all history. -You also want to change the branch name on the remote (GitHub, GitLab, other server). -How do you do this? +Since `option/card-layout` is in this list, Nora knows she can safely delete it without losing any work. -Rename the branch locally with the `git branch --move` command: +To see all the branches that contain work she *hasn't* merged yet: -[source, console] +[source,bash] ---- -$ git branch --move bad-branch-name corrected-branch-name ----- - -This replaces your `bad-branch-name` with `corrected-branch-name`, but this change is only local for now. -To let others see the corrected branch on the remote, push it: - -[source,console] ----- -$ git push --set-upstream origin corrected-branch-name +$ git branch --no-merged + option/list-layout + option/canvas-freeform ---- -Now we'll take a brief look at where we are now: +This is Nora's "to-do" list. It shows her exactly which explorations are still active and haven't been reconciled with the main project yet. -[source, console] ----- -$ git branch --all -* corrected-branch-name - main - remotes/origin/bad-branch-name - remotes/origin/corrected-branch-name - remotes/origin/main ----- +==== Deleting a Branch +tag::procedure[] -Notice that you're on the branch `corrected-branch-name` and it's available on the remote. -However, the branch with the bad name is also still present there but you can delete it by executing the following command: +(((git commands, branch))) +Once an exploration is finished or a fix is merged, Nora should delete the branch to keep the repo clean: -[source,console] +[source,bash] ---- -$ git push origin --delete bad-branch-name +$ git branch -d option/card-layout ---- -Now the bad branch name is fully replaced with the corrected branch name. - -[[_changing_master]] -===== Changing the master branch name - -[WARNING] -==== -Changing the name of a branch like master/main/mainline/default will break the integrations, services, helper utilities and build/release scripts that your repository uses. -Before you do this, make sure you consult with your collaborators. -Also, make sure you do a thorough search through your repo and update any references to the old branch name in your code and scripts. -==== - -Rename your local `master` branch into `main` with the following command: +If Nora tries to delete a branch that *isn't* merged yet (like `option/list-layout`), Git will warn her and protect her work: -[source,console] +[source,bash] ---- -$ git branch --move master main +$ git branch -d option/list-layout +error: The branch 'option/list-layout' is not fully merged. +If you are sure you want to delete it, run 'git branch -D option/list-layout'. ---- -There's no local `master` branch anymore, because it's renamed to the `main` branch. +If Nora is absolutely sure she wants to discard the "list layout" experiment entirely, she can use the capital `-D` flag to force the deletion. -To let others see the new `main` branch, you need to push it to the remote. -This makes the renamed branch available on the remote. +==== Renaming a Branch +tag::procedure[] -[source,console] ----- -$ git push --set-upstream origin main ----- - -Now we end up with the following state: +If Nora wants to rename a branch—for example, to make it more descriptive—she can use the `-m` flag: -[source,console] +[source,bash] ---- -$ git branch --all -* main - remotes/origin/HEAD -> origin/master - remotes/origin/main - remotes/origin/master +$ git branch -m option/card-layout option/results-grid ---- -Your local `master` branch is gone, as it's replaced with the `main` branch. -The `main` branch is present on the remote. -However, the old `master` branch is still present on the remote. -Other collaborators will continue to use the `master` branch as the base of their work, until you make some further changes. - -Now you have a few more tasks in front of you to complete the transition: - -* Any projects that depend on this one will need to update their code and/or configuration. -* Update any test-runner configuration files. -* Adjust build and release scripts. -* Redirect settings on your repo host for things like the repo's default branch, merge rules, and other things that match branch names. -* Update references to the old branch in documentation. -* Close or merge any pull requests that target the old branch. - -After you've done all these tasks, and are certain the `main` branch performs just as the `master` branch, you can delete the `master` branch: - -[source, console] ----- -$ git push origin --delete master ----- +This renames the local branch. If the branch has already been pushed to a server, there are a few more steps to synchronize that change, which we’ll cover in <<_remote_branches>>. diff --git a/book/03-git-branching/sections/nutshell.asc b/book/03-git-branching/sections/nutshell.asc index 2bffd5ddb..8e1a9801b 100644 --- a/book/03-git-branching/sections/nutshell.asc +++ b/book/03-git-branching/sections/nutshell.asc @@ -1,100 +1,64 @@ [[_git_branches_overview]] === Branches in a Nutshell +tag::concept[] -To really understand the way Git does branching, we need to take a step back and examine how Git stores its data. +(((branches))) +Nearly every version control system has some form of branching support. Branching means you diverge from the main line of work and continue to do work without messing with that main line. In many older tools, this was an expensive process, often requiring you to create a new copy of your entire project folder—which could take a long time for large design projects. -As you may remember from <<ch01-getting-started#what_is_git_section>>, Git doesn't store data as a series of changesets or differences, but instead as a series of _snapshots_. +Some people refer to Git's branching model as its "killer feature," and it certainly sets Git apart. Why? Because branching in Git is incredibly **lightweight**. Creating a branch is nearly instantaneous, and switching back and forth is just as fast. -When you make a commit, Git stores a commit object that contains a pointer to the snapshot of the content you staged. -This object also contains the author's name and email address, the message that you typed, and pointers to the commit or commits that directly came before this commit (its parent or parents): zero parents for the initial commit, one parent for a normal commit, and multiple parents for a commit that results from a merge of two or more branches. +For Nora at SketchSpark, branching isn't just a technical feature; it's a way to manage **parallel explorations**. -To visualize this, let's assume that you have a directory containing three files, and you stage them all and commit. -Staging the files computes a checksum for each one (the SHA-1 hash we mentioned in <<ch01-getting-started#what_is_git_section>>), stores that version of the file in the Git repository (Git refers to them as _blobs_), and adds that checksum to the staging area: +==== What is a Branch, Really? +tag::concept[] -[source,console] ----- -$ git add README test.rb LICENSE -$ git commit -m 'Initial commit' ----- - -When you create the commit by running `git commit`, Git checksums each subdirectory (in this case, just the root project directory) and stores them as a tree object in the Git repository. -Git then creates a commit object that has the metadata and a pointer to the root project tree so it can re-create that snapshot when needed.(((git commands, commit))) - -Your Git repository now contains five objects: three _blobs_ (each representing the contents of one of the three files), one _tree_ that lists the contents of the directory and specifies which file names are stored as which blobs, and one _commit_ with the pointer to that root tree and all the commit metadata. +To understand how Git branches so quickly, we need to look at how it stores data. As you remember from <<ch01-getting-started#what_is_git_section>>, Git doesn't store data as a series of changes, but as a series of **snapshots**. -.A commit and its tree -image::images/commit-and-tree.png[A commit and its tree] +When you make a checkpoint (commit), Git stores a commit object that contains a pointer to the snapshot of the content you staged. This object also contains your name, the date, your message, and—crucially—a pointer to the commit that came before it (its parent). -If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it. - -.Commits and their parents -image::images/commits-and-parents.png[Commits and their parents] - -A branch in Git is simply a lightweight movable pointer to one of these commits. -The default branch name in Git is `master`. -As you start making commits, you're given a `master` branch that points to the last commit you made. -Every time you commit, the `master` branch pointer moves forward automatically. - -[NOTE] -==== -The "`master`" branch in Git is not a special branch.(((master))) -It is exactly like any other branch. -The only reason nearly every repository has one is that the `git init` command creates it by default and most people don't bother to change it. -==== +A branch in Git is simply a **lightweight, movable pointer** to one of these commits. The default branch name in Git is `main` (or `master` in older repos). As Nora makes commits, her `main` branch pointer moves forward automatically to the latest one. .A branch and its commit history image::images/branch-and-history.png[A branch and its commit history] -[[_create_new_branch]] ==== Creating a New Branch +tag::procedure[] -(((branches, creating))) -What happens when you create a new branch? -Well, doing so creates a new pointer for you to move around. -Let's say you want to create a new branch called `testing`. -You do this with the `git branch` command:(((git commands, branch))) +(((git commands, branch))) +What happens when Nora wants to try a new idea without breaking her stable research? She creates a new pointer. Let’s say she wants to experiment with a "testing" workflow. She does this with the `git branch` command: -[source,console] +[source,bash] ---- $ git branch testing ---- -This creates a new pointer to the same commit you're currently on. +This creates a new pointer to the exact same commit she is currently on. -.Two branches pointing into the same series of commits +.Two branches pointing to the same checkpoint image::images/two-branches.png[Two branches pointing into the same series of commits] -How does Git know what branch you're currently on? -It keeps a special pointer called `HEAD`. -Note that this is a lot different than the concept of `HEAD` in other VCSs you may be used to, such as Subversion or CVS. -In Git, this is a pointer to the local branch you're currently on. -In this case, you're still on `master`. -The `git branch` command only _created_ a new branch -- it didn't switch to that branch. +How does Git know which branch Nora is currently using? It keeps a special pointer called **HEAD**. At the moment, Nora is still on `main`. The `git branch` command only *created* the new branch; it didn't switch to it. .HEAD pointing to a branch image::images/head-to-master.png[HEAD pointing to a branch] -You can easily see this by running a simple `git log` command that shows you where the branch pointers are pointing. -This option is called `--decorate`. +Nora can see this by running `git log --decorate`: -[source,console] +[source,bash] ---- $ git log --oneline --decorate -f30ab (HEAD -> master, testing) Add feature #32 - ability to add new formats to the central interface -34ac2 Fix bug #1328 - stack overflow under certain conditions -98ca9 Initial commit +f30ab (HEAD -> main, testing) [Research: Product] Add parallel UI goals +34ac2 [Research: Persona] Refine early-adopter goals +98ca9 [Research: Setup] Initial commit ---- -You can see the `master` and `testing` branches that are right there next to the `f30ab` commit. - -[[_switching_branches]] ==== Switching Branches +tag::procedure[] -(((branches, switching))) -To switch to an existing branch, you run the `git checkout` command.(((git commands, checkout))) -Let's switch to the new `testing` branch: +(((git commands, checkout))) +To switch to an existing branch, Nora uses the `git checkout` command (or the newer `git switch`): -[source,console] +[source,bash] ---- $ git checkout testing ---- @@ -104,107 +68,21 @@ This moves `HEAD` to point to the `testing` branch. .HEAD points to the current branch image::images/head-to-testing.png[HEAD points to the current branch] -What is the significance of that? -Well, let's do another commit: +Now, if Nora makes a new commit—perhaps adding a note about "AI model speed"—her `testing` branch moves forward, but her `main` branch stays exactly where it was. -[source,console] +[source,bash] ---- -$ vim test.rb -$ git commit -a -m 'Make a change' +$ git commit -a -m "[Research: Model] Add notes on generation speed" ---- -.The HEAD branch moves forward when a commit is made +.The HEAD branch moves forward with new work image::images/advance-testing.png[The HEAD branch moves forward when a commit is made] -This is interesting, because now your `testing` branch has moved forward, but your `master` branch still points to the commit you were on when you ran `git checkout` to switch branches. -Let's switch back to the `master` branch: +If Nora switches back to `main`, Git rewinds her project folder to look exactly like it did before she started the "testing" experiment. -[source,console] +[source,bash] ---- -$ git checkout master +$ git checkout main ---- -[NOTE] -.`git log` doesn't show _all_ the branches _all_ the time -==== -If you were to run `git log` right now, you might wonder where the "testing" branch you just created went, as it would not appear in the output. - -The branch hasn't disappeared; Git just doesn't know that you're interested in that branch and it is trying to show you what it thinks you're interested in. -In other words, by default, `git log` will only show commit history below the branch you've checked out. - -To show commit history for the desired branch you have to explicitly specify it: `git log testing`. -To show all of the branches, add `--all` to your `git log` command. -==== - -.HEAD moves when you checkout -image::images/checkout-master.png[HEAD moves when you checkout] - -That command did two things. -It moved the HEAD pointer back to point to the `master` branch, and it reverted the files in your working directory back to the snapshot that `master` points to. -This also means the changes you make from this point forward will diverge from an older version of the project. -It essentially rewinds the work you've done in your `testing` branch so you can go in a different direction. - -[NOTE] -.Switching branches changes files in your working directory -==== -It's important to note that when you switch branches in Git, files in your working directory will change. -If you switch to an older branch, your working directory will be reverted to look like it did the last time you committed on that branch. -If Git cannot do it cleanly, it will not let you switch at all. -==== - -Let's make a few changes and commit again: - -[source,console] ----- -$ vim test.rb -$ git commit -a -m 'Make other changes' ----- - -Now your project history has diverged (see <<divergent_history>>). -You created and switched to a branch, did some work on it, and then switched back to your main branch and did other work. -Both of those changes are isolated in separate branches: you can switch back and forth between the branches and merge them together when you're ready. -And you did all that with simple `branch`, `checkout`, and `commit` commands. - -[[divergent_history]] -.Divergent history -image::images/advance-master.png[Divergent history] - -You can also see this easily with the `git log` command. -If you run `git log --oneline --decorate --graph --all` it will print out the history of your commits, showing where your branch pointers are and how your history has diverged. - -[source,console] ----- -$ git log --oneline --decorate --graph --all -* c2b9e (HEAD, master) Make other changes -| * 87ab2 (testing) Make a change -|/ -* f30ab Add feature #32 - ability to add new formats to the central interface -* 34ac2 Fix bug #1328 - stack overflow under certain conditions -* 98ca9 Initial commit of my project ----- - -Because a branch in Git is actually a simple file that contains the 40 character SHA-1 checksum of the commit it points to, branches are cheap to create and destroy. -Creating a new branch is as quick and simple as writing 41 bytes to a file (40 characters and a newline). - -This is in sharp contrast to the way most older VCS tools branch, which involves copying all of the project's files into a second directory. -This can take several seconds or even minutes, depending on the size of the project, whereas in Git the process is always instantaneous. -Also, because we're recording the parents when we commit, finding a proper merge base for merging is automatically done for us and is generally very easy to do. -These features help encourage developers to create and use branches often. - -Let's see why you should do so. - -[NOTE] -.Creating a new branch and switching to it at the same time -==== -It's typical to create a new branch and want to switch to that new branch at the same time -- this can be done in one operation with `git checkout -b <newbranchname>`. -==== - -[NOTE] -==== -From Git version 2.23 onwards you can use `git switch` instead of `git checkout` to: - -- Switch to an existing branch: `git switch testing-branch`. -- Create a new branch and switch to it: `git switch -c new-branch`. - The `-c` flag stands for create, you can also use the full flag: `--create`. -- Return to your previously checked out branch: `git switch -`. -==== +This allows Nora to experiment freely. If an idea in the `testing` branch fails, she can just delete it and her `main` branch remains untouched. If it succeeds, she can merge it back in. This "siloed" way of working is what makes Git so powerful for creative teams. diff --git a/book/03-git-branching/sections/rebasing.asc b/book/03-git-branching/sections/rebasing.asc index c66535246..b476bc082 100644 --- a/book/03-git-branching/sections/rebasing.asc +++ b/book/03-git-branching/sections/rebasing.asc @@ -1,240 +1,62 @@ -[[_rebasing]] === Rebasing +tag::concept[] (((rebasing))) -In Git, there are two main ways to integrate changes from one branch into another: the `merge` and the `rebase`. -In this section you'll learn what rebasing is, how to do it, why it's a pretty amazing tool, and in what cases you won't want to use it. +In Git, there are two main ways to integrate changes from one branch into another: the `merge` and the `rebase`. In this section, you’ll learn what rebasing is, how to do it, and why it can make your design project’s history much easier to read. ==== The Basic Rebase +tag::procedure[] -If you go back to an earlier example from <<_basic_merging>>, you can see that you diverged your work and made commits on two different branches. +Suppose Sam has diverged his work, creating a layout exploration while Nora made research updates on `main`. -.Simple divergent history +.Divergent history: Research vs. UI exploration image::images/basic-rebase-1.png[Simple divergent history] -The easiest way to integrate the branches, as we've already covered, is the `merge` command. -It performs a three-way merge between the two latest branch snapshots (`C3` and `C4`) and the most recent common ancestor of the two (`C2`), creating a new snapshot (and commit). +As we’ve seen, Nora could **merge** these two. This creates a "merge commit" that ties the two branches together. However, there is another way: she can take the patch of the change Sam made and **reapply** it on top of her latest work. In Git, this is called **rebasing**. -[[rebasing-merging-example]] -.Merging to integrate diverged work history -image::images/basic-rebase-2.png[Merging to integrate diverged work history] - -However, there is another way: you can take the patch of the change that was introduced in `C4` and reapply it on top of `C3`. -In Git, this is called _rebasing_. -With the `rebase` command, you can take all the changes that were committed on one branch and replay them on a different branch.(((git commands, rebase))) - -For this example, you would check out the `experiment` branch, and then rebase it onto the `master` branch as follows: - -[source,console] ----- -$ git checkout experiment -$ git rebase master -First, rewinding head to replay your work on top of it... -Applying: added staged command ----- - -This operation works by going to the common ancestor of the two branches (the one you're on and the one you're rebasing onto), getting the diff introduced by each commit of the branch you're on, saving those diffs to temporary files, resetting the current branch to the same commit as the branch you are rebasing onto, and finally applying each change in turn. - -.Rebasing the change introduced in `C4` onto `C3` -image::images/basic-rebase-3.png[Rebasing the change introduced in `C4` onto `C3`] - -At this point, you can go back to the `master` branch and do a fast-forward merge. - -[source,console] ----- -$ git checkout master -$ git merge experiment ----- - -.Fast-forwarding the `master` branch -image::images/basic-rebase-4.png[Fast-forwarding the `master` branch] - -Now, the snapshot pointed to by `C4'` is exactly the same as the one that was pointed to by `C5` in <<rebasing-merging-example,the merge example>>. -There is no difference in the end product of the integration, but rebasing makes for a cleaner history. -If you examine the log of a rebased branch, it looks like a linear history: it appears that all the work happened in series, even when it originally happened in parallel. - -Often, you'll do this to make sure your commits apply cleanly on a remote branch -- perhaps in a project to which you're trying to contribute but that you don't maintain. -In this case, you'd do your work in a branch and then rebase your work onto `origin/master` when you were ready to submit your patches to the main project. -That way, the maintainer doesn't have to do any integration work -- just a fast-forward or a clean apply. - -Note that the snapshot pointed to by the final commit you end up with, whether it's the last of the rebased commits for a rebase or the final merge commit after a merge, is the same snapshot -- it's only the history that is different. -Rebasing replays changes from one line of work onto another in the order they were introduced, whereas merging takes the endpoints and merges them together. - -==== More Interesting Rebases - -You can also have your rebase replay on something other than the rebase target branch. -Take a history like <<rbdiag_e>>, for example. -You branched a topic branch (`server`) to add some server-side functionality to your project, and made a commit. -Then, you branched off that to make the client-side changes (`client`) and committed a few times. -Finally, you went back to your `server` branch and did a few more commits. - -[[rbdiag_e]] -.A history with a topic branch off another topic branch -image::images/interesting-rebase-1.png[A history with a topic branch off another topic branch] - -Suppose you decide that you want to merge your client-side changes into your mainline for a release, but you want to hold off on the server-side changes until it's tested further. -You can take the changes on `client` that aren't on `server` (`C8` and `C9`) and replay them on your `master` branch by using the `--onto` option of `git rebase`: - -[source,console] ----- -$ git rebase --onto master server client ----- - -This basically says, "`Take the `client` branch, figure out the patches since it diverged from the `server` branch, and replay these patches in the `client` branch as if it was based directly off the `master` branch instead.`" -It's a bit complex, but the result is pretty cool. - -.Rebasing a topic branch off another topic branch -image::images/interesting-rebase-2.png[Rebasing a topic branch off another topic branch] - -Now you can fast-forward your `master` branch (see <<rbdiag_g>>): - -[source,console] ----- -$ git checkout master -$ git merge client ----- - -[[rbdiag_g]] -.Fast-forwarding your `master` branch to include the `client` branch changes -image::images/interesting-rebase-3.png[Fast-forwarding your `master` branch to include the `client` branch changes] - -Let's say you decide to pull in your `server` branch as well. -You can rebase the `server` branch onto the `master` branch without having to check it out first by running `git rebase <basebranch> <topicbranch>` -- which checks out the topic branch (in this case, `server`) for you and replays it onto the base branch (`master`): - -[source,console] +[source,bash] ---- -$ git rebase master server +$ git checkout option/card-layout +$ git rebase main ---- -This replays your `server` work on top of your `master` work, as shown in <<rbdiag_h>>. +This operation works by going back to the common ancestor of the two branches, getting the diff introduced by Sam's branch, and "replaying" his changes on top of Nora's latest work. -[[rbdiag_h]] -.Rebasing your `server` branch on top of your `master` branch -image::images/interesting-rebase-4.png[Rebasing your `server` branch on top of your `master` branch] +.Replaying Sam's work on top of Nora's latest research +image::images/basic-rebase-3.png[Rebasing diagram] -Then, you can fast-forward the base branch (`master`): +Now Sam's exploration is directly ahead of `main`. Nora can switch back to `main` and do a fast-forward merge: -[source,console] +[source,bash] ---- -$ git checkout master -$ git merge server +$ git checkout main +$ git merge option/card-layout ---- -You can remove the `client` and `server` branches because all the work is integrated and you don't need them anymore, leaving your history for this entire process looking like <<rbdiag_i>>: - -[source,console] ----- -$ git branch -d client -$ git branch -d server ----- +.A linear history: as if Sam and Nora worked in series +image::images/basic-rebase-4.png[Fast-forwarding after rebase] -[[rbdiag_i]] -.Final commit history -image::images/interesting-rebase-5.png[Final commit history] +The end result is identical to a merge, but the **history is cleaner**. If Nora looks at the log, it appears as though all the work happened in one straight line, making it much easier for stakeholders to follow the evolution of the project. -[[_rebase_peril]] ==== The Perils of Rebasing +tag::warning[] (((rebasing, perils of))) -Ahh, but the bliss of rebasing isn't without its drawbacks, which can be summed up in a single line: - -*Do not rebase commits that exist outside your repository and that people may have based work on.* - -If you follow that guideline, you'll be fine. -If you don't, people will hate you, and you'll be scorned by friends and family. - -When you rebase stuff, you're abandoning existing commits and creating new ones that are similar but different. -If you push commits somewhere and others pull them down and base work on them, and then you rewrite those commits with `git rebase` and push them up again, your collaborators will have to re-merge their work and things will get messy when you try to pull their work back into yours. - -Let's look at an example of how rebasing work that you've made public can cause problems. -Suppose you clone from a central server and then do some work off that. -Your commit history looks like this: - -.Clone a repository, and base some work on it -image::images/perils-of-rebasing-1.png["Clone a repository, and base some work on it"] - -Now, someone else does more work that includes a merge, and pushes that work to the central server. -You fetch it and merge the new remote branch into your work, making your history look something like this: - -.Fetch more commits, and merge them into your work -image::images/perils-of-rebasing-2.png["Fetch more commits, and merge them into your work"] - -Next, the person who pushed the merged work decides to go back and rebase their work instead; they do a `git push --force` to overwrite the history on the server. -You then fetch from that server, bringing down the new commits. - -[[_pre_merge_rebase_work]] -.Someone pushes rebased commits, abandoning commits you've based your work on -image::images/perils-of-rebasing-3.png["Someone pushes rebased commits, abandoning commits you've based your work on"] - -Now you're both in a pickle. -If you do a `git pull`, you'll create a merge commit which includes both lines of history, and your repository will look like this: - -[[_merge_rebase_work]] -.You merge in the same work again into a new merge commit -image::images/perils-of-rebasing-4.png[You merge in the same work again into a new merge commit] - -If you run a `git log` when your history looks like this, you'll see two commits that have the same author, date, and message, which will be confusing. -Furthermore, if you push this history back up to the server, you'll reintroduce all those rebased commits to the central server, which can further confuse people. -It's pretty safe to assume that the other developer doesn't want `C4` and `C6` to be in the history; that's why they rebased in the first place. - -[[_rebase_rebase]] -==== Rebase When You Rebase - -If you *do* find yourself in a situation like this, Git has some further magic that might help you out. -If someone on your team force pushes changes that overwrite work that you've based work on, your challenge is to figure out what is yours and what they've rewritten. - -It turns out that in addition to the commit SHA-1 checksum, Git also calculates a checksum that is based just on the patch introduced with the commit. -This is called a "`patch-id`". - -If you pull down work that was rewritten and rebase it on top of the new commits from your partner, Git can often successfully figure out what is uniquely yours and apply them back on top of the new branch. - -For instance, in the previous scenario, if instead of doing a merge when we're at <<_pre_merge_rebase_work>> we run `git rebase teamone/master`, Git will: - -* Determine what work is unique to our branch (`C2`, `C3`, `C4`, `C6`, `C7`) -* Determine which are not merge commits (`C2`, `C3`, `C4`) -* Determine which have not been rewritten into the target branch (just `C2` and `C3`, since `C4` is the same patch as `C4'`) -* Apply those commits to the top of `teamone/master` - -So instead of the result we see in <<_merge_rebase_work>>, we would end up with something more like <<_rebase_rebase_work>>. - -[[_rebase_rebase_work]] -.Rebase on top of force-pushed rebase work -image::images/perils-of-rebasing-5.png[Rebase on top of force-pushed rebase work] - -This only works if `C4` and `C4'` that your partner made are almost exactly the same patch. -Otherwise the rebase won't be able to tell that it's a duplicate and will add another `C4`-like patch (which will probably fail to apply cleanly, since the changes would already be at least somewhat there). - -You can also simplify this by running a `git pull --rebase` instead of a normal `git pull`. -Or you could do it manually with a `git fetch` followed by a `git rebase teamone/master` in this case. - -If you are using `git pull` and want to make `--rebase` the default, you can set the `pull.rebase` config value with something like `git config --global pull.rebase true`. - -If you only ever rebase commits that have never left your own computer, you'll be just fine. -If you rebase commits that have been pushed, but that no one else has based commits from, you'll also be fine. -If you rebase commits that have already been pushed publicly, and people may have based work on those commits, then you may be in for some frustrating trouble, and the scorn of your teammates. +Rebasing is a powerful tool, but it comes with a golden rule that Nora and Sam must follow: -If you or a partner does find it necessary at some point, make sure everyone knows to run `git pull --rebase` to try to make the pain after it happens a little bit simpler. +**Do not rebase commits that you have already pushed to a shared server.** -==== Rebase vs. Merge +When you rebase, you are technically abandoning old commits and creating new ones that look the same but have different SHA-1 IDs. If Nora rebases her local work on top of Sam's, but Sam has already pulled her original commits and based his own work on them, the histories will clash. -(((rebasing, vs. merging)))(((merging, vs. rebasing))) -Now that you've seen rebasing and merging in action, you may be wondering which one is better. -Before we can answer this, let's step back a bit and talk about what history means. +If you follow this rule, you’ll be fine. If you don’t, your teammates will see duplicate commits and confusing merge conflicts the next time they pull. -One point of view on this is that your repository's commit history is a *record of what actually happened.* -It's a historical document, valuable in its own right, and shouldn't be tampered with. -From this angle, changing the commit history is almost blasphemous; you're _lying_ about what actually transpired. -So what if there was a messy series of merge commits? -That's how it happened, and the repository should preserve that for posterity. +==== Rebase vs. Merge: Which is Better? +tag::concept[] -The opposing point of view is that the commit history is the *story of how your project was made.* -You wouldn't publish the first draft of a book, so why show your messy work? -When you're working on a project, you may need a record of all your missteps and dead-end paths, but when it's time to show your work to the world, you may want to tell a more coherent story of how to get from A to B. -People in this camp use tools like `rebase` and `filter-branch` to rewrite their commits before they're merged into the mainline branch. -They use tools like `rebase` and `filter-branch`, to tell the story in the way that's best for future readers. +(((rebasing, vs. merging))) +So, should Nora merge or rebase? It depends on how she thinks about history. -Now, to the question of whether merging or rebasing is better: hopefully you'll see that it's not that simple. -Git is a powerful tool, and allows you to do many things to and with your history, but every team and every project is different. -Now that you know how both of these things work, it's up to you to decide which one is best for your particular situation. +* **History as a Record:** If Nora believes the commit history should be a 100% accurate record of *what actually happened* (including all the messy divergent paths), she should **merge**. +* **History as a Story:** If Nora believes the history is the **story of how the project was made**, she should **rebase**. Just as a designer wouldn't show every messy rough sketch to a client, she might want to rebase her local explorations into a clean, logical progression before sharing them with the world. -You can get the best of both worlds: rebase local changes before pushing to clean up your work, but never rebase anything that you've pushed somewhere. +There is no "right" answer. Many teams choose a hybrid approach: they rebase their local work to clean it up before pushing, but they never rebase the shared `main` branch. diff --git a/book/03-git-branching/sections/remote-branches.asc b/book/03-git-branching/sections/remote-branches.asc index adbb8735d..45b8caf51 100644 --- a/book/03-git-branching/sections/remote-branches.asc +++ b/book/03-git-branching/sections/remote-branches.asc @@ -1,236 +1,89 @@ [[_remote_branches]] === Remote Branches +tag::concept[] (((branches, remote)))(((references, remote))) -Remote references are references (pointers) in your remote repositories, including branches, tags, and so on. -You can get a full list of remote references explicitly with `git ls-remote <remote>`, or `git remote show <remote>` for remote branches as well as more information. -Nevertheless, a more common way is to take advantage of remote-tracking branches. - -Remote-tracking branches are references to the state of remote branches. -They're local references that you can't move; Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository. -Think of them as bookmarks, to remind you where the branches in your remote repositories were the last time you connected to them. - -Remote-tracking branch names take the form `<remote>/<branch>`. -For instance, if you wanted to see what the `master` branch on your `origin` remote looked like as of the last time you communicated with it, you would check the `origin/master` branch. -If you were working on an issue with a partner and they pushed up an `iss53` branch, you might have your own local `iss53` branch, but the branch on the server would be represented by the remote-tracking branch `origin/iss53`. - -This may be a bit confusing, so let's look at an example. -Let's say you have a Git server on your network at `git.ourcompany.com`. -If you clone from this, Git's `clone` command automatically names it `origin` for you, pulls down all its data, creates a pointer to where its `master` branch is, and names it `origin/master` locally. -Git also gives you your own local `master` branch starting at the same place as origin's `master` branch, so you have something to work from. - -[NOTE] -."`origin`" is not special -==== -Just like the branch name "`master`" does not have any special meaning in Git, neither does "`origin`". -While "`master`" is the default name for a starting branch when you run `git init` which is the only reason it's widely used, "`origin`" is the default name for a remote when you run `git clone`. -If you run `git clone -o booyah` instead, then you will have `booyah/master` as your default remote branch.(((origin))) -==== +Remote references are pointers in your remote repositories (like on GitHub or GitLab). They tell you where your branches, tags, and other references were the last time you communicated with the server. -.Server and local repositories after cloning -image::images/remote-branches-1.png[Server and local repositories after cloning] - -If you do some work on your local `master` branch, and, in the meantime, someone else pushes to `git.ourcompany.com` and updates its `master` branch, then your histories move forward differently. -Also, as long as you stay out of contact with your `origin` server, your `origin/master` pointer doesn't move. - -.Local and remote work can diverge -image::images/remote-branches-2.png[Local and remote work can diverge] +The most common way to interact with these is through **remote-tracking branches**. Think of them as bookmarks to remind you where the branches in your remote repositories were the last time you connected to them. They take the form `<remote>/<branch>`. -To synchronize your work with a given remote, you run a `git fetch <remote>` command (in our case, `git fetch origin`). -This command looks up which server "`origin`" is (in this case, it's `git.ourcompany.com`), fetches any data from it that you don't yet have, and updates your local database, moving your `origin/master` pointer to its new, more up-to-date position. +For example, if Nora wants to see what the `main` branch on the SketchSpark server (`origin`) looked like when she last pulled, she looks at `origin/main`. If Sam pushes a new exploration branch called `option/card-layout`, Nora will see it as `origin/option/card-layout` once she fetches. -.`git fetch` updates your remote-tracking branches -image::images/remote-branches-3.png[`git fetch` updates your remote-tracking branches] +==== How They Work +tag::concept[] -To demonstrate having multiple remote servers and what remote branches for those remote projects look like, let's assume you have another internal Git server that is used only for development by one of your sprint teams. -This server is at `git.team1.ourcompany.com`. -You can add it as a new remote reference to the project you're currently working on by running the `git remote add` command as we covered in <<ch02-git-basics-chapter#ch02-git-basics-chapter>>. -Name this remote `teamone`, which will be your shortname for that whole URL. +Suppose Nora and her team have a shared Git server for SketchSpark. When Nora clones from this server, Git automatically names the remote `origin` for her, pulls down all its data, and creates a local pointer to where its `main` branch is, calling it `origin/main`. -.Adding another server as a remote -image::images/remote-branches-4.png[Adding another server as a remote] - -Now, you can run `git fetch teamone` to fetch everything the remote `teamone` server has that you don't have yet. -Because that server has a subset of the data your `origin` server has right now, Git fetches no data but sets a remote-tracking branch called `teamone/master` to point to the commit that `teamone` has as its `master` branch. - -.Remote-tracking branch for `teamone/master` -image::images/remote-branches-5.png[Remote-tracking branch for `teamone/master`] - -[[_pushing_branches]] -==== Pushing - -(((pushing))) -When you want to share a branch with the world, you need to push it up to a remote to which you have write access. -Your local branches aren't automatically synchronized to the remotes you write to -- you have to explicitly push the branches you want to share. -That way, you can use private branches for work you don't want to share, and push up only the topic branches you want to collaborate on. - -If you have a branch named `serverfix` that you want to work on with others, you can push it up the same way you pushed your first branch. -Run `git push <remote> <branch>`:(((git commands, push))) - -[source,console] ----- -$ git push origin serverfix -Counting objects: 24, done. -Delta compression using up to 8 threads. -Compressing objects: 100% (15/15), done. -Writing objects: 100% (24/24), 1.91 KiB | 0 bytes/s, done. -Total 24 (delta 2), reused 0 (delta 0) -To https://github.com/schacon/simplegit - * [new branch] serverfix -> serverfix ----- - -This is a bit of a shortcut. -Git automatically expands the `serverfix` branchname out to `refs/heads/serverfix:refs/heads/serverfix`, which means, "`Take my `serverfix` local branch and push it to update the remote's `serverfix` branch.`" -We'll go over the `refs/heads/` part in detail in <<ch10-git-internals#ch10-git-internals>>, but you can generally leave it off. -You can also do `git push origin serverfix:serverfix`, which does the same thing -- it says, "`Take my serverfix and make it the remote's serverfix.`" -You can use this format to push a local branch into a remote branch that is named differently. -If you didn't want it to be called `serverfix` on the remote, you could instead run `git push origin serverfix:awesomebranch` to push your local `serverfix` branch to the `awesomebranch` branch on the remote project. - -[NOTE] -.Don't type your password every time -==== -If you're using an HTTPS URL to push over, the Git server will ask you for your username and password for authentication. -By default it will prompt you on the terminal for this information so the server can tell if you're allowed to push. +.Server and local repositories after cloning +image::images/remote-branches-1.png[Server and local repositories after cloning] -If you don't want to type it every single time you push, you can set up a "`credential cache`". -The simplest is just to keep it in memory for a few minutes, which you can easily set up by running `git config --global credential.helper cache`. +If Nora does some work locally on `main`, and Sam simultaneously pushes a change to the server’s `main` branch, their histories will diverge. Nora’s local `main` moves forward, but her `origin/main` bookmark doesn't move until she talks to the server again. -For more information on the various credential caching options available, see <<ch07-git-tools#_credential_caching>>. -==== +.Local and remote work can diverge +image::images/remote-branches-2.png[Local and remote work can diverge] -The next time one of your collaborators fetches from the server, they will get a reference to where the server's version of `serverfix` is under the remote branch `origin/serverfix`: +To synchronize her work, Nora runs: -[source,console] +[source,bash] ---- $ git fetch origin -remote: Counting objects: 7, done. -remote: Compressing objects: 100% (2/2), done. -remote: Total 3 (delta 0), reused 3 (delta 0) -Unpacking objects: 100% (3/3), done. -From https://github.com/schacon/simplegit - * [new branch] serverfix -> origin/serverfix ---- -It's important to note that when you do a fetch that brings down new remote-tracking branches, you don't automatically have local, editable copies of them. -In other words, in this case, you don't have a new `serverfix` branch -- you have only an `origin/serverfix` pointer that you can't modify. +This command looks up which server `origin` is, fetches any data from it that Nora doesn't have yet, and updates her local database, moving her `origin/main` bookmark to its new, most up-to-date position. -To merge this work into your current working branch, you can run `git merge origin/serverfix`. -If you want your own `serverfix` branch that you can work on, you can base it off your remote-tracking branch: +==== Pushing Your Work +tag::procedure[] -[source,console] ----- -$ git checkout -b serverfix origin/serverfix -Branch serverfix set up to track remote branch serverfix from origin. -Switched to a new branch 'serverfix' ----- - -This gives you a local branch that you can work on that starts where `origin/serverfix` is. - -[[_tracking_branches]] -==== Tracking Branches - -(((branches, tracking)))(((branches, upstream))) -Checking out a local branch from a remote-tracking branch automatically creates what is called a "`tracking branch`" (and the branch it tracks is called an "`upstream branch`"). -Tracking branches are local branches that have a direct relationship to a remote branch. -If you're on a tracking branch and type `git pull`, Git automatically knows which server to fetch from and which branch to merge in. +(((pushing))) +When Nora wants to share a branch with Sam and Priya, she needs to "push" it to the remote. Local branches aren't automatically shared; Nora must explicitly choose which ones to publish. -When you clone a repository, it generally automatically creates a `master` branch that tracks `origin/master`. -However, you can set up other tracking branches if you wish -- ones that track branches on other remotes, or don't track the `master` branch. -The simple case is the example you just saw, running `git checkout -b <branch> <remote>/<branch>`. -This is a common enough operation that Git provides the `--track` shorthand: +If she has a branch named `feature/onboarding-illustrations` that she wants Priya to see, she runs: -[source,console] +[source,bash] ---- -$ git checkout --track origin/serverfix -Branch serverfix set up to track remote branch serverfix from origin. -Switched to a new branch 'serverfix' +$ git push origin feature/onboarding-illustrations ---- -In fact, this is so common that there's even a shortcut for that shortcut. -If the branch name you're trying to checkout (a) doesn't exist and (b) exactly matches a name on only one remote, Git will create a tracking branch for you: - -[source,console] ----- -$ git checkout serverfix -Branch serverfix set up to track remote branch serverfix from origin. -Switched to a new branch 'serverfix' ----- +This tells Git: "Take my local `feature/onboarding-illustrations` branch and update the `feature/onboarding-illustrations` branch on the server." -To set up a local branch with a different name than the remote branch, you can easily use the first version with a different local branch name: +==== Tracking Branches +tag::concept[] -[source,console] ----- -$ git checkout -b sf origin/serverfix -Branch sf set up to track remote branch serverfix from origin. -Switched to a new branch 'sf' ----- +(((branches, tracking))) +When Nora checks out a local branch from a remote-tracking branch, Git automatically creates a **tracking branch**. This is a local branch that has a direct relationship with a remote branch. -Now, your local branch `sf` will automatically pull from `origin/serverfix`. +If she's on a tracking branch and types `git pull`, Git already knows which server to fetch from and which branch to merge in. -If you already have a local branch and want to set it to a remote branch you just pulled down, or want to change the upstream branch you're tracking, you can use the `-u` or `--set-upstream-to` option to `git branch` to explicitly set it at any time. +If Sam has pushed a branch called `fix/color-contrast`, Nora can start working on it locally like this: -[source,console] +[source,bash] ---- -$ git branch -u origin/serverfix -Branch serverfix set up to track remote branch serverfix from origin. +$ git checkout fix/color-contrast +Branch 'fix/color-contrast' set up to track remote branch 'fix/color-contrast' from 'origin'. +Switched to a new branch 'fix/color-contrast' ---- -[NOTE] -.Upstream shorthand -==== -When you have a tracking branch set up, you can reference its upstream branch with the `@{upstream}` or `@{u}` shorthand. -So if you're on the `master` branch and it's tracking `origin/master`, you can say something like `git merge @{u}` instead of `git merge origin/master` if you wish.(((@{u})))(((@{upstream}))) -==== +To see which local branches are tracking which remote ones, Nora can use the `-vv` flag: -If you want to see what tracking branches you have set up, you can use the `-vv` option to `git branch`. -This will list out your local branches with more information including what each branch is tracking and if your local branch is ahead, behind or both. - -[source,console] +[source,bash] ---- $ git branch -vv - iss53 7e424c3 [origin/iss53: ahead 2] Add forgotten brackets - master 1ae2a45 [origin/master] Deploy index fix -* serverfix f8674d9 [teamone/server-fix-good: ahead 3, behind 1] This should do it - testing 5ea463a Try something new ----- - -So here we can see that our `iss53` branch is tracking `origin/iss53` and is "`ahead`" by two, meaning that we have two commits locally that are not pushed to the server. -We can also see that our `master` branch is tracking `origin/master` and is up to date. -Next we can see that our `serverfix` branch is tracking the `server-fix-good` branch on our `teamone` server and is ahead by three and behind by one, meaning that there is one commit on the server we haven't merged in yet and three commits locally that we haven't pushed. -Finally we can see that our `testing` branch is not tracking any remote branch. - -It's important to note that these numbers are only since the last time you fetched from each server. -This command does not reach out to the servers, it's telling you about what it has cached from these servers locally. -If you want totally up to date ahead and behind numbers, you'll need to fetch from all your remotes right before running this. -You could do that like this: - -[source,console] + feature/onboarding [origin/feature/onboarding: ahead 2] [Design: Onboarding] Add step 1... +* main [origin/main] [Research: Product] Add parallel UI goals + fix/color-contrast [origin/fix/color-contrast: behind 1] [Fix: Contrast] Initial audit ---- -$ git fetch --all; git branch -vv ----- - -==== Pulling -(((pulling))) -While the `git fetch` command will fetch all the changes on the server that you don't have yet, it will not modify your working directory at all. -It will simply get the data for you and let you merge it yourself. -However, there is a command called `git pull` which is essentially a `git fetch` immediately followed by a `git merge` in most cases. -If you have a tracking branch set up as demonstrated in the last section, either by explicitly setting it or by having it created for you by the `clone` or `checkout` commands, `git pull` will look up what server and branch your current branch is tracking, fetch from that server and then try to merge in that remote branch. +This shows that Nora's `feature/onboarding` branch is "ahead" by 2 commits (she hasn't pushed yet), and her `fix/color-contrast` is "behind" by 1 (Sam has pushed a new update she hasn't pulled yet). -[[_delete_branches]] ==== Deleting Remote Branches +tag::procedure[] (((branches, deleting remote))) -Suppose you're done with a remote branch -- say you and your collaborators are finished with a feature and have merged it into your remote's `master` branch (or whatever branch your stable codeline is in). -You can delete a remote branch using the `--delete` option to `git push`. -If you want to delete your `serverfix` branch from the server, you run the following: +Once Nora and Sam have merged a feature into `main`, they should clean up the server by deleting the remote branch: -[source,console] +[source,bash] ---- -$ git push origin --delete serverfix -To https://github.com/schacon/simplegit - - [deleted] serverfix +$ git push origin --delete fix/color-contrast ---- -Basically all this does is to remove the pointer from the server. -The Git server will generally keep the data there for a while until a garbage collection runs, so if it was accidentally deleted, it's often easy to recover. +Basically, this just removes the pointer from the server. The data will stick around for a while, so if it was an accident, it’s often recoverable. diff --git a/book/03-git-branching/sections/workflows.asc b/book/03-git-branching/sections/workflows.asc index 9e6f3922a..df678e116 100644 --- a/book/03-git-branching/sections/workflows.asc +++ b/book/03-git-branching/sections/workflows.asc @@ -1,63 +1,49 @@ === Branching Workflows +tag::concept[] -Now that you have the basics of branching and merging down, what can or should you do with them? -In this section, we'll cover some common workflows that this lightweight branching makes possible, so you can decide if you would like to incorporate them into your own development cycle. +Now that you know the basics of branching and merging, what can you do with them? In this section, we’ll cover some common workflows that this lightweight branching makes possible, so you can decide if you’d like to incorporate them into your own design cycle. -==== Long-Running Branches +==== Progressive-Stability Branching +tag::concept[] -(((branches, long-running))) -Because Git uses a simple three-way merge, merging from one branch into another multiple times over a long period is generally easy to do. -This means you can have several branches that are always open and that you use for different stages of your development cycle; you can merge regularly from some of them into others. +Many Git teams use a workflow that focuses on the stability of their work. In this setup, Nora might maintain a `main` branch that only contains work that is entirely stable—perhaps only the code and design that has been or will be released to the public. -Many Git developers have a workflow that embraces this approach, such as having only code that is entirely stable in their `master` branch -- possibly only code that has been or will be released. -They have another parallel branch named `develop` or `next` that they work from or use to test stability -- it isn't necessarily always stable, but whenever it gets to a stable state, it can be merged into `master`. -It's used to pull in topic branches (short-lived branches, like your earlier `iss53` branch) when they're ready, to make sure they pass all the tests and don't introduce bugs. - -In reality, we're talking about pointers moving up the line of commits you're making. -The stable branches are farther down the line in your commit history, and the bleeding-edge branches are farther up the history. +She might also have a parallel branch named `develop` that her team works from. The `develop` branch is where Sam and Priya merge their explorations. Whenever the `develop` branch reaches a stable state, Nora merges it into `main`. .A linear view of progressive-stability branching image::images/lr-branches-1.png[A linear view of progressive-stability branching] -It's generally easier to think about them as work silos, where sets of commits graduate to a more stable silo when they're fully tested. +It’s often easier to think about these as **work silos**, where sets of commits graduate to a more stable silo when they’re fully tested. -[[lrbranch_b]] -.A "`silo`" view of progressive-stability branching +.A "silo" view of progressive-stability branching image::images/lr-branches-2.png[A “silo” view of progressive-stability branching] -You can keep doing this for several levels of stability. -Some larger projects also have a `proposed` or `pu` (proposed updates) branch that has integrated branches that may not be ready to go into the `next` or `master` branch. -The idea is that your branches are at various levels of stability; when they reach a more stable level, they're merged into the branch above them. -Again, having multiple long-running branches isn't necessary, but it's often helpful, especially when you're dealing with very large or complex projects. +Some larger projects add even more layers, like a `proposed` branch for experimental features that aren't even ready for `develop` yet. The idea is that your branches are at various levels of stability; when they reach a more stable level, they’re merged into the branch above them. -[[_topic_branch]] ==== Topic Branches +tag::concept[] (((branches, topic))) -Topic branches, however, are useful in projects of any size. -A topic branch is a short-lived branch that you create and use for a single particular feature or related work. -This is something you've likely never done with a VCS before because it's generally too expensive to create and merge branches. -But in Git it's common to create, work on, merge, and delete branches several times a day. +Topic branches are useful in projects of any size. A topic branch is a short-lived branch that Nora or Sam creates for a single particular feature or related work. You’ve already seen this with Sam’s `option/card-layout` and `fix/upload-error-state` branches. -You saw this in the last section with the `iss53` and `hotfix` branches you created. -You did a few commits on them and deleted them directly after merging them into your main branch. -This technique allows you to context-switch quickly and completely -- because your work is separated into silos where all the changes in that branch have to do with that topic, it's easier to see what has happened during code review and such. -You can keep the changes there for minutes, days, or months, and merge them in when they're ready, regardless of the order in which they were created or worked on. +This technique allows the team to **context-switch** quickly and completely. Because their work is separated into silos where all the changes in that branch have to do with that specific topic, it’s easier to see what has happened during design review. Nora can keep an exploration active for minutes, days, or months, and merge it in only when it’s ready, regardless of the order in which it was created. -Consider an example of doing some work (on `master`), branching off for an issue (`iss91`), working on it for a bit, branching off the second branch to try another way of handling the same thing (`iss91v2`), going back to your `master` branch and working there for a while, and then branching off there to do some work that you're not sure is a good idea (`dumbidea` branch). -Your commit history will look something like this: +Consider Sam’s workflow: +1. Work on `main`. +2. Branch off for a new layout exploration (`option/results-v2`). +3. Work on it for a bit. +4. Branch off *that* branch to try a different color scheme (`option/results-v2-darkmode`). +5. Go back to `main` to handle a quick fix. +6. Branch off `main` to try a "dumb idea" he had in the shower (`dumbidea`). -.Multiple topic branches -image::images/topic-branches-1.png[Multiple topic branches] +His commit history would look something like this: -Now, let's say you decide you like the second solution to your issue best (`iss91v2`); and you showed the `dumbidea` branch to your coworkers, and it turns out to be genius. -You can throw away the original `iss91` branch (losing commits `C5` and `C6`) and merge in the other two. -Your history then looks like this: +.Multiple topic branches for parallel exploration +image::images/topic-branches-1.png[Multiple topic branches] -.History after merging `dumbidea` and `iss91v2` -image::images/topic-branches-2.png[History after merging `dumbidea` and `iss91v2`] +Now, Sam decides he likes the "dark mode" solution best, and his "dumb idea" turned out to be a breakthrough. He can throw away the original `option/results-v2` branch and merge in the other two. -We will go into more detail about the various possible workflows for your Git project in <<ch05-distributed-git#ch05-distributed-git>>, so before you decide which branching scheme your next project will use, be sure to read that chapter. +.History after merging the best explorations +image::images/topic-branches-2.png[History after merging] -It's important to remember when you're doing all this that these branches are completely local. -When you're branching and merging, everything is being done only in your Git repository -- there is no communication with the server. +It’s important to remember that all this branching and merging is done **completely locally** in your own repo. No communication with a server is needed until you're ready to share. diff --git a/book/04-git-server/sections/generating-ssh-key.asc b/book/04-git-server/sections/generating-ssh-key.asc index d1a61daf4..a95b2d586 100644 --- a/book/04-git-server/sections/generating-ssh-key.asc +++ b/book/04-git-server/sections/generating-ssh-key.asc @@ -1,57 +1,51 @@ [[_generate_ssh_key]] === Generating Your SSH Public Key +tag::procedure[] (((SSH keys))) -Many Git servers authenticate using SSH public keys. -In order to provide a public key, each user in your system must generate one if they don't already have one. -This process is similar across all operating systems. -First, you should check to make sure you don't already have a key. -By default, a user's SSH keys are stored in that user's `~/.ssh` directory. -You can easily check to see if you have a key already by going to that directory and listing the contents: - -[source,console] +Many Git servers—including GitHub—authenticate using SSH public keys. Before Sam can push his card layout explorations to Nora's server, he needs to generate a key pair. + +Think of an SSH key pair like a physical lock and its key. +* The **Public Key** (`.pub` file) is the "lock." Sam can give this to anyone (or put it on any server). +* The **Private Key** is the "key." Sam must keep this safely on his computer and never share it. + +==== Checking for Existing Keys +tag::procedure[] + +First, Sam should check if he already has a key. On his Mac (or on a Windows machine using Git Bash), he opens the terminal and lists the contents of his `.ssh` directory: + +[source,bash] ---- -$ cd ~/.ssh -$ ls -authorized_keys2 id_dsa known_hosts -config id_dsa.pub +$ ls ~/.ssh +authorized_keys id_rsa id_rsa.pub known_hosts ---- -You're looking for a pair of files named something like `id_dsa` or `id_rsa` and a matching file with a `.pub` extension. -The `.pub` file is your public key, and the other file is the corresponding private key. -If you don't have these files (or you don't even have a `.ssh` directory), you can create them by running a program called `ssh-keygen`, which is provided with the SSH package on Linux/macOS systems and comes with Git for Windows: +He’s looking for a pair of files named something like `id_rsa` and `id_rsa.pub`. If he sees them, he can skip the next step. + +==== Generating a New Key +tag::procedure[] + +If Sam doesn't have a key, he can create one using the `ssh-keygen` tool: -[source,console] +[source,bash] ---- $ ssh-keygen -o Generating public/private rsa key pair. -Enter file in which to save the key (/home/schacon/.ssh/id_rsa): -Created directory '/home/schacon/.ssh'. -Enter passphrase (empty for no passphrase): -Enter same passphrase again: -Your identification has been saved in /home/schacon/.ssh/id_rsa. -Your public key has been saved in /home/schacon/.ssh/id_rsa.pub. -The key fingerprint is: -d0:82:24:8e:d7:f1:bb:9b:33:53:96:93:49:da:9b:e3 schacon@mylaptop.local +Enter file in which to save the key (/Users/sam/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: ---- -First it confirms where you want to save the key (`.ssh/id_rsa`), and then it asks twice for a passphrase, which you can leave empty if you don't want to type a password when you use the key. -However, if you do use a password, make sure to add the `-o` option; it saves the private key in a format that is more resistant to brute-force password cracking than is the default format. -You can also use the `ssh-agent` tool to prevent having to enter the password each time. +First, it asks where to save the key (the default is usually fine). Then it asks for a **passphrase**. While Sam can leave this empty, adding a passphrase provides an extra layer of security—even if someone steals his computer, they won't be able to use his key without the password. -Now, each user that does this has to send their public key to you or whoever is administrating the Git server (assuming you're using an SSH server setup that requires public keys). -All they have to do is copy the contents of the `.pub` file and email it. -The public keys look something like this: +Once complete, his keys are saved. The public key looks something like this: -[source,console] +[source,bash] ---- $ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3 -Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA -t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En -mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx -NrRFi9wrf+M7Q== schacon@mylaptop.local +... sam@sketchspark-laptop.local ---- -For a more in-depth tutorial on creating an SSH key on multiple operating systems, see the GitHub guide on SSH keys at https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent[^]. +Sam just needs to copy the entire contents of that `.pub` file and send it to Nora (or paste it into his GitHub settings). He is now ready to securely collaborate on the SketchSpark project. diff --git a/book/04-git-server/sections/git-on-a-server.asc b/book/04-git-server/sections/git-on-a-server.asc index 61847a993..6cb7f591f 100644 --- a/book/04-git-server/sections/git-on-a-server.asc +++ b/book/04-git-server/sections/git-on-a-server.asc @@ -1,101 +1,55 @@ [[_getting_git_on_a_server]] === Getting Git on a Server +tag::concept[] -Now we'll cover setting up a Git service running these protocols on your own server. +In order to initially set up any Git server, you have to export an existing repository into a new **bare repository**—a repository that doesn’t contain a working directory. -[NOTE] -==== -Here we'll be demonstrating the commands and steps needed to do basic, simplified installations on a Linux-based server, though it's also possible to run these services on macOS or Windows servers. -Actually setting up a production server within your infrastructure will certainly entail differences in security measures or operating system tools, but hopefully this will give you the general idea of what's involved. -==== +Think of a normal repository (like Nora's `sketchspark` folder) as a "working studio": it has the history (the `.git` folder) and all the files she is currently editing. A **bare** repository is just the history. It's the "central brain" of the project, intended only for sharing and backups. Conventionally, bare repository directory names end with the suffix `.git`. -In order to initially set up any Git server, you have to export an existing repository into a new bare repository -- a repository that doesn't contain a working directory. -This is generally straightforward to do. -In order to clone your repository to create a new bare repository, you run the clone command with the `--bare` option.(((git commands, clone, bare))) -By convention, bare repository directory names end with the suffix `.git`, like so: +==== Creating a Bare Repository +tag::procedure[] -[source,console] ----- -$ git clone --bare my_project my_project.git -Cloning into bare repository 'my_project.git'... -done. ----- - -You should now have a copy of the Git directory data in your `my_project.git` directory. - -This is roughly equivalent to something like: +(((git commands, clone, bare))) +To create a bare version of her project, Nora uses the `--bare` option with the `clone` command: -[source,console] +[source,bash] ---- -$ cp -Rf my_project/.git my_project.git +$ git clone --bare sketchspark sketchspark.git +Cloning into bare repository 'sketchspark.git'... +done. ---- -There are a couple of minor differences in the configuration file but, for your purpose, this is close to the same thing. -It takes the Git repository by itself, without a working directory, and creates a directory specifically for it alone. +Nora now has a directory named `sketchspark.git` that contains only the Git data. This is what she will put on the team's server. [[_bare_repo]] ==== Putting the Bare Repository on a Server +tag::procedure[] + +Suppose Nora has a small Linux server she uses for internal tools, reachable at `git.sketchspark.io`. She has SSH access to this server and wants to store the repo under `/srv/git`. -Now that you have a bare copy of your repository, all you need to do is put it on a server and set up your protocols. -Let's say you've set up a server called `git.example.com` to which you have SSH access, and you want to store all your Git repositories under the `/srv/git` directory. -Assuming that `/srv/git` exists on that server, you can set up your new repository by copying your bare repository over: +First, she copies her bare repository to the server: -[source,console] +[source,bash] ---- -$ scp -r my_project.git user@git.example.com:/srv/git +$ scp -r sketchspark.git nora@git.sketchspark.io:/srv/git ---- -At this point, other users who have SSH-based read access to the `/srv/git` directory on that server can clone your repository by running: +At this point, Sam or Priya can clone the repository to their own machines: -[source,console] +[source,bash] ---- -$ git clone user@git.example.com:/srv/git/my_project.git +$ git clone nora@git.sketchspark.io:/srv/git/sketchspark.git ---- -If a user SSHs into a server and has write access to the `/srv/git/my_project.git` directory, they will also automatically have push access. +If Nora wants to make sure the file permissions are set correctly for a shared team, she can log into the server and run `git init --shared`: -Git will automatically add group write permissions to a repository properly if you run the `git init` command with the `--shared` option. -Note that by running this command, you will not destroy any commits, refs, etc. in the process.(((git commands, init, bare))) - -[source,console] +[source,bash] ---- -$ ssh user@git.example.com -$ cd /srv/git/my_project.git +$ ssh nora@git.sketchspark.io +$ cd /srv/git/sketchspark.git $ git init --bare --shared ---- -You see how easy it is to take a Git repository, create a bare version, and place it on a server to which you and your collaborators have SSH access. -Now you're ready to collaborate on the same project. - -It's important to note that this is literally all you need to do to run a useful Git server to which several people have access -- just add SSH-able accounts on a server, and stick a bare repository somewhere that all those users have read and write access to. -You're ready to go -- nothing else needed. - -In the next few sections, you'll see how to expand to more sophisticated setups. -This discussion will include not having to create user accounts for each user, adding public read access to repositories, setting up web UIs and more. -However, keep in mind that to collaborate with a couple of people on a private project, all you _need_ is an SSH server and a bare repository. - -==== Small Setups - -If you're a small outfit or are just trying out Git in your organization and have only a few developers, things can be simple for you. -One of the most complicated aspects of setting up a Git server is user management. -If you want some repositories to be read-only for certain users and read/write for others, access and permissions can be a bit more difficult to arrange. - -===== SSH Access - -(((serving repositories, SSH))) -If you have a server to which all your developers already have SSH access, it's generally easiest to set up your first repository there, because you have to do almost no work (as we covered in the last section). -If you want more complex access control type permissions on your repositories, you can handle them with the normal filesystem permissions of your server's operating system. - -If you want to place your repositories on a server that doesn't have accounts for everyone on your team for whom you want to grant write access, then you must set up SSH access for them. -We assume that if you have a server with which to do this, you already have an SSH server installed, and that's how you're accessing the server. - -There are a few ways you can give access to everyone on your team. -The first is to set up accounts for everybody, which is straightforward but can be cumbersome. -You may not want to run `adduser` (or the possible alternative `useradd`) and have to set temporary passwords for every new user. - -A second method is to create a single 'git' user account on the machine, ask every user who is to have write access to send you an SSH public key, and add that key to the `~/.ssh/authorized_keys` file of that new 'git' account. -At that point, everyone will be able to access that machine via the 'git' account. -This doesn't affect the commit data in any way -- the SSH user you connect as doesn't affect the commits you've recorded. +This ensures that anyone in the team's group can read and write to the repository. -Another way to do it is to have your SSH server authenticate from an LDAP server or some other centralized authentication source that you may already have set up. -As long as each user can get shell access on the machine, any SSH authentication mechanism you can think of should work. +As you can see, setting up a "Git Server" can be as simple as having an SSH account and a bare repository. There is no special "Git software" to install on the server—just Git itself. For a small team of designers, this might be all you ever need. However, as Nora will soon discover, hosted options like GitHub offer much more than just a place to store files. diff --git a/book/04-git-server/sections/hosted.asc b/book/04-git-server/sections/hosted.asc index 54eb79334..c1cc680d7 100644 --- a/book/04-git-server/sections/hosted.asc +++ b/book/04-git-server/sections/hosted.asc @@ -1,10 +1,13 @@ === Third Party Hosted Options +tag::concept[] -If you don't want to go through all of the work involved in setting up your own Git server, you have several options for hosting your Git projects on an external dedicated hosting site. -Doing so offers a number of advantages: a hosting site is generally quick to set up and easy to start projects on, and no server maintenance or monitoring is involved. -Even if you set up and run your own server internally, you may still want to use a public hosting site for your open source code -- it's generally easier for the open source community to find and help you with. +If Nora doesn't want to go through the work of setting up and maintaining her own Linux server, she has several options for hosting the SketchSpark project on a dedicated site. -These days, you have a huge number of hosting options to choose from, each with different advantages and disadvantages. -To see an up-to-date list, check out the GitHosting page on the main Git wiki at https://archive.kernel.org/oldwiki/git.wiki.kernel.org/index.php/GitHosting.html[^]. +Using a hosted service offers several advantages for a design team: +* **Quick Setup:** You can start a new project in seconds. +* **Zero Maintenance:** No server updates, backups, or security monitoring to worry about. +* **Collaboration Features:** Most hosts provide a web interface for reviewing changes, managing issues, and protecting branches (ensuring nobody accidentally overwrites the `main` branch). -We'll cover using GitHub in detail in <<ch06-github#ch06-github>>, as it is the largest Git host out there and you may need to interact with projects hosted on it in any case, but there are dozens more to choose from should you not want to set up your own Git server. +These days, Nora has many options to choose from, including GitLab, Bitbucket, and GitHub. Each has its own strengths, but for a startup like SketchSpark that wants to be part of the larger open-source design community, one choice stands out. + +We’ll cover using **GitHub** in detail in <<ch06-github#ch06-github>>. It is the largest Git host in the world and offers a suite of tools specifically designed to make team collaboration easier—from pull request reviews to integrated task tracking. For Nora, Sam, and Priya, GitHub will become the "home" of the SketchSpark project. diff --git a/book/04-git-server/sections/protocols.asc b/book/04-git-server/sections/protocols.asc index ff226d1e6..c02ce241f 100644 --- a/book/04-git-server/sections/protocols.asc +++ b/book/04-git-server/sections/protocols.asc @@ -1,211 +1,62 @@ === The Protocols +tag::concept[] -Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH) and Git. -Here we'll discuss what they are and in what basic circumstances you would want (or not want) to use them. +Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH), and Git. For Nora and the SketchSpark team, choosing the right protocol is a balance between security, speed, and ease of use for the designers. ==== Local Protocol +tag::concept[] (((protocols, local))) -The most basic is the _Local protocol_, in which the remote repository is in another directory on the same host. -This is often used if everyone on your team has access to a shared filesystem such as an https://en.wikipedia.org/wiki/Network_File_System[NFS^] mount, or in the less likely case that everyone logs in to the same computer. -The latter wouldn't be ideal, because all your code repository instances would reside on the same computer, making a catastrophic loss much more likely. +The most basic is the **Local protocol**, where the remote repository is simply another directory on the same computer or a shared network drive. -If you have a shared mounted filesystem, then you can clone, push to, and pull from a local file-based repository. -To clone a repository like this, or to add one as a remote to an existing project, use the path to the repository as the URL. -For example, to clone a local repository, you can run something like this: +If Nora had a shared office server that everyone could mount as a drive, she could add it as a remote: -[source,console] +[source,bash] ---- -$ git clone /srv/git/project.git +$ git remote add office-server /Volumes/designs/sketchspark.git ---- -Or you can do this: +**The Pros:** It's simple and uses existing file permissions. It’s a great way to quickly grab a layout from a teammate's computer if you're on the same network. -[source,console] ----- -$ git clone file:///srv/git/project.git ----- - -Git operates slightly differently if you explicitly specify `file://` at the beginning of the URL. -If you just specify the path, Git tries to use hardlinks or directly copy the files it needs. -If you specify `file://`, Git fires up the processes that it normally uses to transfer data over a network, which is generally much less efficient. -The main reason to specify the `file://` prefix is if you want a clean copy of the repository with extraneous references or objects left out -- generally after an import from another VCS or something similar (see <<ch10-git-internals#ch10-git-internals>> for maintenance tasks). -We'll use the normal path here because doing so is almost always faster. - -To add a local repository to an existing Git project, you can run something like this: - -[source,console] ----- -$ git remote add local_proj /srv/git/project.git ----- - -Then, you can push to and pull from that remote via your new remote name `local_proj` as though you were doing so over a network. - -===== The Pros - -The pros of file-based repositories are that they're simple and they use existing file permissions and network access. -If you already have a shared filesystem to which your whole team has access, setting up a repository is very easy. -You stick the bare repository copy somewhere everyone has shared access to and set the read/write permissions as you would for any other shared directory. -We'll discuss how to export a bare repository copy for this purpose in <<ch04-git-on-the-server#_getting_git_on_a_server>>. - -This is also a nice option for quickly grabbing work from someone else's working repository. -If you and a co-worker are working on the same project and they want you to check something out, running a command like `git pull /home/john/project` is often easier than them pushing to a remote server and you subsequently fetching from it. - -===== The Cons - -The cons of this method are that shared access is generally more difficult to set up and reach from multiple locations than basic network access. -If you want to push from your laptop when you're at home, you have to mount the remote disk, which can be difficult and slow compared to network-based access. - -It's important to mention that this isn't necessarily the fastest option if you're using a shared mount of some kind. -A local repository is fast only if you have fast access to the data. -A repository on NFS is often slower than the repository over SSH on the same server, allowing Git to run off local disks on each system. - -Finally, this protocol does not protect the repository against accidental damage. -Every user has full shell access to the "`remote`" directory, and there is nothing preventing them from changing or removing internal Git files and corrupting the repository. +**The Cons:** Shared drives are often slow and difficult to reach from home. More importantly, this protocol doesn’t protect the repository against accidental damage—anyone with access to the drive could accidentally delete the internal Git files. ==== The HTTP Protocols +tag::concept[] -Git can communicate over HTTP using two different modes. -Prior to Git 1.6.6, there was only one way it could do this which was very simple and generally read-only. -In version 1.6.6, a new, smarter protocol was introduced that involved Git being able to intelligently negotiate data transfer in a manner similar to how it does over SSH. -In the last few years, this new HTTP protocol has become very popular since it's simpler for the user and smarter about how it communicates. -The newer version is often referred to as the _Smart_ HTTP protocol and the older way as _Dumb_ HTTP. -We'll cover the newer Smart HTTP protocol first. - -===== Smart HTTP - -(((protocols, smart HTTP))) -Smart HTTP operates very similarly to the SSH or Git protocols but runs over standard HTTPS ports and can use various HTTP authentication mechanisms, meaning it's often easier on the user than something like SSH, since you can use things like username/password authentication rather than having to set up SSH keys. +(((protocols, HTTP))) +Git can communicate over HTTP in two ways: "Smart" and "Dumb." Today, almost everyone uses **Smart HTTP**. -It has probably become the most popular way to use Git now, since it can be set up to both serve anonymously like the `git://` protocol, and can also be pushed over with authentication and encryption like the SSH protocol. -Instead of having to set up different URLs for these things, you can now use a single URL for both. -If you try to push and the repository requires authentication (which it normally should), the server can prompt for a username and password. -The same goes for read access. +Smart HTTP operates over standard HTTPS ports (like a regular website) and is likely the most popular way to use Git today. It allows for both anonymous read-only access (for public design systems) and authenticated push access (for Nora and Sam). -In fact, for services like GitHub, the URL you use to view the repository online (for example, https://github.com/schacon/simplegit[^]) is the same URL you can use to clone and, if you have access, push over. - -===== Dumb HTTP - -(((protocols, dumb HTTP))) -If the server does not respond with a Git HTTP smart service, the Git client will try to fall back to the simpler _Dumb_ HTTP protocol. -The Dumb protocol expects the bare Git repository to be served like normal files from the web server. -The beauty of Dumb HTTP is the simplicity of setting it up. -Basically, all you have to do is put a bare Git repository under your HTTP document root and set up a specific `post-update` hook, and you're done (see <<ch08-customizing-git#_git_hooks>>). -At that point, anyone who can access the web server under which you put the repository can also clone your repository. -To allow read access to your repository over HTTP, do something like this: - -[source,console] ----- -$ cd /var/www/htdocs/ -$ git clone --bare /path/to/git_project gitproject.git -$ cd gitproject.git -$ mv hooks/post-update.sample hooks/post-update -$ chmod a+x hooks/post-update ----- +**The Pros:** It’s incredibly easy for users. You can use a single URL for everything, and it works through almost all corporate firewalls. You can authenticate with a standard username and password (which can be saved in your Mac’s Keychain or Windows Credential Manager). -That's all.(((hooks, post-update))) -The `post-update` hook that comes with Git by default runs the appropriate command (`git update-server-info`) to make HTTP fetching and cloning work properly. -This command is run when you push to this repository (over SSH perhaps); then, other people can clone via something like: - -[source,console] ----- -$ git clone https://example.com/gitproject.git ----- - -In this particular case, we're using the `/var/www/htdocs` path that is common for Apache setups, but you can use any static web server -- just put the bare repository in its path. -The Git data is served as basic static files (see the <<ch10-git-internals#ch10-git-internals>> chapter for details about exactly how it's served). - -Generally you would either choose to run a read/write Smart HTTP server or simply have the files accessible as read-only in the Dumb manner. -It's rare to run a mix of the two services. - -===== The Pros - -We'll concentrate on the pros of the Smart version of the HTTP protocol. - -The simplicity of having a single URL for all types of access and having the server prompt only when authentication is needed makes things very easy for the end user. -Being able to authenticate with a username and password is also a big advantage over SSH, since users don't have to generate SSH keys locally and upload their public key to the server before being able to interact with it. -For less sophisticated users, or users on systems where SSH is less common, this is a major advantage in usability. -It is also a very fast and efficient protocol, similar to the SSH one. - -You can also serve your repositories read-only over HTTPS, which means you can encrypt the content transfer; or you can go so far as to make the clients use specific signed SSL certificates. - -Another nice thing is that HTTP and HTTPS are such commonly used protocols that corporate firewalls are often set up to allow traffic through their ports. - -===== The Cons - -Git over HTTPS can be a little more tricky to set up compared to SSH on some servers. -Other than that, there is very little advantage that other protocols have over Smart HTTP for serving Git content. - -If you're using HTTP for authenticated pushing, providing your credentials is sometimes more complicated than using keys over SSH. -There are, however, several credential caching tools you can use, including Keychain access on macOS and Credential Manager on Windows, to make this pretty painless. -Read <<ch07-git-tools#_credential_caching>> to see how to set up secure HTTP password caching on your system. +**The Cons:** On some servers, setting up Smart HTTP can be more complex than SSH. ==== The SSH Protocol +tag::concept[] (((protocols, SSH))) -A common transport protocol for Git when self-hosting is over SSH. -This is because SSH access to servers is already set up in most places -- and if it isn't, it's easy to do. -SSH is also an authenticated network protocol and, because it's ubiquitous, it's generally easy to set up and use. - -To clone a Git repository over SSH, you can specify an `ssh://` URL like this: - -[source,console] ----- -$ git clone ssh://[user@]server/project.git ----- +A very common protocol for self-hosting design repos is **SSH (Secure Shell)**. This is an authenticated protocol that is built into almost every modern operating system. -Or you can use the shorter scp-like syntax for the SSH protocol: +To clone Nora's repo over SSH, Sam would use a URL like this: -[source,console] +[source,bash] ---- -$ git clone [user@]server:project.git +$ git clone git@server:sketchspark.git ---- -In both cases above, if you don't specify the optional username, Git assumes the user you're currently logged in as. +**The Pros:** It’s very secure—all data transfer is encrypted. It’s also very efficient, making the data as compact as possible before sending it across the network. -===== The Pros +**The Cons:** It doesn't support anonymous access. Everyone who wants to see the project *must* have an account on the server. It also requires Nora and Sam to generate "SSH keys," which we’ll cover in <<_generate_ssh_key>>. -The pros of using SSH are many. -First, SSH is relatively easy to set up -- SSH daemons are commonplace, many network admins have experience with them, and many OS distributions are set up with them or have tools to manage them. -Next, access over SSH is secure -- all data transfer is encrypted and authenticated. -Last, like the HTTPS, Git and Local protocols, SSH is efficient, making the data as compact as possible before transferring it. +==== The Git Protocol +tag::concept[] -===== The Cons +(((protocols, git))) +Finally, there is the **Git protocol**. This is a special tool packaged with Git that listens on a dedicated port (9418). It’s similar to SSH but has **zero authentication**. -The negative aspect of SSH is that it doesn't support anonymous access to your Git repository. -If you're using SSH, people _must_ have SSH access to your machine, even in a read-only capacity, which doesn't make SSH conducive to open source projects for which people might simply want to clone your repository to examine it. -If you're using it only within your corporate network, SSH may be the only protocol you need to deal with. -If you want to allow anonymous read-only access to your projects and also want to use SSH, you'll have to set up SSH for you to push over but something else for others to fetch from. +**The Pros:** It is often the fastest network protocol available. If you're serving a massive, public-facing design system with thousands of users, this is the way to go. -==== The Git Protocol +**The Cons:** It lacks security. Because there is no authentication, Nora can't safely allow people to push changes over this protocol. Anyone who finds the URL could potentially overwrite the SketchSpark project. It’s also often blocked by corporate firewalls. -(((protocols, git))) -Finally, we have the Git protocol. -This is a special daemon that comes packaged with Git; it listens on a dedicated port (9418) that provides a service similar to the SSH protocol, but with absolutely no authentication or cryptography. -In order for a repository to be served over the Git protocol, you must create a `git-daemon-export-ok` file -- the daemon won't serve a repository without that file in it -- but, other than that, there is no security. -Either the Git repository is available for everyone to clone, or it isn't. -This means that there is generally no pushing over this protocol. -You can enable push access but, given the lack of authentication, anyone on the internet who finds your project's URL could push to that project. -Suffice it to say that this is rare. - -===== The Pros - -The Git protocol is often the fastest network transfer protocol available. -If you're serving a lot of traffic for a public project or serving a very large project that doesn't require user authentication for read access, it's likely that you'll want to set up a Git daemon to serve your project. -It uses the same data-transfer mechanism as the SSH protocol but without the encryption and authentication overhead. - -===== The Cons - -Due to the lack of TLS or other cryptography, cloning over `git://` might lead to an arbitrary code execution vulnerability, and should therefore be avoided unless you know what you are doing. - -* If you run `git clone git://example.com/project.git`, an attacker who controls e.g your router can modify the repo you just cloned, inserting malicious code into it. - If you then compile/run the code you just cloned, you will execute the malicious code. - Running `git clone http://example.com/project.git` should be avoided for the same reason. -* Running `git clone https://example.com/project.git` does not suffer from the same problem (unless the attacker can provide a TLS certificate for example.com). - Running `git clone git@example.com:project.git` only suffers from this problem if you accept a wrong SSH key fingerprint. - -It also has no authentication, i.e. anyone can clone the repo (although this is often exactly what you want). -It's also probably the most difficult protocol to set up. -It must run its own daemon, which requires `xinetd` or `systemd` configuration or the like, which isn't always a walk in the park. -It also requires firewall access to port 9418, which isn't a standard port that corporate firewalls always allow. -Behind big corporate firewalls, this obscure port is commonly blocked. +For Nora, the choice boils down to **SSH** for team security or **Smart HTTP** for ease of use. As we’ll see, a hosted service like GitHub will allow her to use both simultaneously. diff --git a/book/05-distributed-git/sections/contributing.asc b/book/05-distributed-git/sections/contributing.asc index 2c6b08516..3270b6db5 100644 --- a/book/05-distributed-git/sections/contributing.asc +++ b/book/05-distributed-git/sections/contributing.asc @@ -1,802 +1,59 @@ [[_contributing_project]] === Contributing to a Project +tag::concept[] (((contributing))) -The main difficulty with describing how to contribute to a project are the numerous variations on how to do that. -Because Git is very flexible, people can and do work together in many ways, and it's problematic to describe how you should contribute -- every project is a bit different. -Some of the variables involved are active contributor count, chosen workflow, your commit access, and possibly the external contribution method. +The way you contribute to a project depends on your role and the team’s workflow. Because Git is so flexible, every project is a bit different. For Sam, a UI Designer at SketchSpark, contributing means pushing his latest Figma-exported PNGs and updating the design tokens. For Marcus, a community contributor, it means suggesting a fix for a contrast error in those same tokens. -The first variable is active contributor count -- how many users are actively contributing code to this project, and how often? -In many instances, you'll have two or three developers with a few commits a day, or possibly less for somewhat dormant projects. -For larger companies or projects, the number of developers could be in the thousands, with hundreds or thousands of commits coming in each day. -This is important because with more and more developers, you run into more issues with making sure your code applies cleanly or can be easily merged. -Changes you submit may be rendered obsolete or severely broken by work that is merged in while you were working or while your changes were waiting to be approved or applied. -How can you keep your code consistently up to date and your commits valid? - -The next variable is the workflow in use for the project. -Is it centralized, with each developer having equal write access to the main codeline? -Does the project have a maintainer or integration manager who checks all the patches? -Are all the patches peer-reviewed and approved? -Are you involved in that process? -Is a lieutenant system in place, and do you have to submit your work to them first? - -The next variable is your commit access. -The workflow required in order to contribute to a project is much different if you have write access to the project than if you don't. -If you don't have write access, how does the project prefer to accept contributed work? -Does it even have a policy? -How much work are you contributing at a time? -How often do you contribute? - -All these questions can affect how you contribute effectively to a project and what workflows are preferred or available to you. -We'll cover aspects of each of these in a series of use cases, moving from simple to more complex; you should be able to construct the specific workflows you need in practice from these examples. - -[[_commit_guidelines]] ==== Commit Guidelines +tag::procedure[] -Before we start looking at the specific use cases, here's a quick note about commit messages. -Having a good guideline for creating commits and sticking to it makes working with Git and collaborating with others a lot easier. -The Git project provides a document that lays out a number of good tips for creating commits from which to submit patches -- you can read it in the Git source code in the `Documentation/SubmittingPatches` file. - -(((git commands, diff, check))) -First, your submissions should not contain any whitespace errors. -Git provides an easy way to check for this -- before you commit, run `git diff --check`, which identifies possible whitespace errors and lists them for you. - -.Output of `git diff --check` -image::images/git-diff-check.png[Output of `git diff --check`] - -If you run that command before committing, you can tell if you're about to commit whitespace issues that may annoy other developers. - -Next, try to make each commit a logically separate changeset. -If you can, try to make your changes digestible -- don't code for a whole weekend on five different issues and then submit them all as one massive commit on Monday. -Even if you don't commit during the weekend, use the staging area on Monday to split your work into at least one commit per issue, with a useful message per commit. -If some of the changes modify the same file, try to use `git add --patch` to partially stage files (covered in detail in <<ch07-git-tools#_interactive_staging>>). -The project snapshot at the tip of the branch is identical whether you do one commit or five, as long as all the changes are added at some point, so try to make things easier on your fellow developers when they have to review your changes. +Before Sam starts pushing work, Nora has established some "ground rules" for the team's history. A project's commit history isn't just for Git—it's for the designers who have to read it six months from now. -This approach also makes it easier to pull out or revert one of the changesets if you need to later. -<<ch07-git-tools#_rewriting_history>> describes a number of useful Git tricks for rewriting history and interactively staging files -- use these tools to help craft a clean and understandable history before sending the work to someone else. - -The last thing to keep in mind is the commit message. -Getting in the habit of creating quality commit messages makes using and collaborating with Git a lot easier. -As a general rule, your messages should start with a single line that's no more than about 50 characters and that describes the changeset concisely, followed by a blank line, followed by a more detailed explanation. -The Git project requires that the more detailed explanation include your motivation for the change and contrast its implementation with previous behavior -- this is a good guideline to follow. -Write your commit message in the imperative: "Fix bug" and not "Fixed bug" or "Fixes bug." -Here is a template you can follow, which we've lightly adapted from one https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[originally written by Tim Pope^]: +* **Clean your workspace:** Sam should avoid committing "junk" files (like `.DS_Store` or Figma auto-backups). We already handled this with `.gitignore` in Chapter 2. +* **Atomic Commits:** Sam should commit one "idea" at a time. If he updates the primary button color *and* fixes a typo in the login screen, those should be two separate checkpoints. +* **Quality Messages:** The SketchSpark team uses a prefix convention: `[Phase: Component]`. [source,text] ---- -Capitalized, short (50 chars or less) summary - -More detailed explanatory text, if necessary. Wrap it to about 72 -characters or so. In some contexts, the first line is treated as the -subject of an email and the rest of the text as the body. The blank -line separating the summary from the body is critical (unless you omit -the body entirely); tools like rebase will confuse you if you run the -two together. - -Write your commit message in the imperative: "Fix bug" and not "Fixed bug" -or "Fixes bug." This convention matches up with commit messages generated -by commands like git merge and git revert. - -Further paragraphs come after blank lines. - -- Bullet points are okay, too - -- Typically a hyphen or asterisk is used for the bullet, followed by a - single space, with blank lines in between, but conventions vary here - -- Use a hanging indent ----- - -If all your commit messages follow this model, things will be much easier for you and the developers with whom you collaborate. -The Git project has well-formatted commit messages -- try running `git log --no-merges` there to see what a nicely-formatted project-commit history looks like. - -[NOTE] -.Do as we say, not as we do. -==== -For the sake of brevity, many of the examples in this book don't have nicely-formatted commit messages like this; instead, we simply use the `-m` option to `git commit`. - -In short, do as we say, not as we do. -==== - -[[_private_team]] -==== Private Small Team - -(((contributing, private small team))) -The simplest setup you're likely to encounter is a private project with one or two other developers. -"`Private,`" in this context, means closed-source -- not accessible to the outside world. -You and the other developers all have push access to the repository. - -In this environment, you can follow a workflow similar to what you might do when using Subversion or another centralized system. -You still get the advantages of things like offline committing and vastly simpler branching and merging, but the workflow can be very similar; the main difference is that merges happen client-side rather than on the server at commit time. -Let's see what it might look like when two developers start to work together with a shared repository. -The first developer, John, clones the repository, makes a change, and commits locally. -The protocol messages have been replaced with `...` in these examples to shorten them somewhat. - -[source,console] ----- -# John's Machine -$ git clone john@githost:simplegit.git -Cloning into 'simplegit'... -... -$ cd simplegit/ -$ vim lib/simplegit.rb -$ git commit -am 'Remove invalid default value' -[master 738ee87] Remove invalid default value - 1 files changed, 1 insertions(+), 1 deletions(-) ----- - -The second developer, Jessica, does the same thing -- clones the repository and commits a change: - -[source,console] ----- -# Jessica's Machine -$ git clone jessica@githost:simplegit.git -Cloning into 'simplegit'... -... -$ cd simplegit/ -$ vim TODO -$ git commit -am 'Add reset task' -[master fbff5bc] Add reset task - 1 files changed, 1 insertions(+), 0 deletions(-) ----- - -Now, Jessica pushes her work to the server, which works just fine: - -[source,console] ----- -# Jessica's Machine -$ git push origin master -... -To jessica@githost:simplegit.git - 1edee6b..fbff5bc master -> master ----- - -The last line of the output above shows a useful return message from the push operation. -The basic format is `<oldref>..<newref> fromref -> toref`, where `oldref` means the old reference, `newref` means the new reference, `fromref` is the name of the local reference being pushed, and `toref` is the name of the remote reference being updated. -You'll see similar output like this below in the discussions, so having a basic idea of the meaning will help in understanding the various states of the repositories. -More details are available in the documentation for https://git-scm.com/docs/git-push[git-push^]. - -Continuing with this example, shortly afterwards, John makes some changes, commits them to his local repository, and tries to push them to the same server: - -[source,console] ----- -# John's Machine -$ git push origin master -To john@githost:simplegit.git - ! [rejected] master -> master (non-fast forward) -error: failed to push some refs to 'john@githost:simplegit.git' ----- - -In this case, John's push fails because of Jessica's earlier push of _her_ changes. -This is especially important to understand if you're used to Subversion, because you'll notice that the two developers didn't edit the same file. -Although Subversion automatically does such a merge on the server if different files are edited, with Git, you must _first_ merge the commits locally. -In other words, John must first fetch Jessica's upstream changes and merge them into his local repository before he will be allowed to push. - -As a first step, John fetches Jessica's work (this only _fetches_ Jessica's upstream work, it does not yet merge it into John's work): - -[source,console] ----- -$ git fetch origin -... -From john@githost:simplegit - + 049d078...fbff5bc master -> origin/master ----- - -At this point, John's local repository looks something like this: - -.John's divergent history -image::images/small-team-1.png[John's divergent history] - -Now John can merge Jessica's work that he fetched into his own local work: - -[source,console] ----- -$ git merge origin/master -Merge made by the 'recursive' strategy. - TODO | 1 + - 1 files changed, 1 insertions(+), 0 deletions(-) ----- - -As long as that local merge goes smoothly, John's updated history will now look like this: - -.John's repository after merging `origin/master` -image::images/small-team-2.png[John's repository after merging `origin/master`] - -At this point, John might want to test this new code to make sure none of Jessica's work affects any of his and, as long as everything seems fine, he can finally push the new merged work up to the server: - -[source,console] ----- -$ git push origin master -... -To john@githost:simplegit.git - fbff5bc..72bbc59 master -> master ----- - -In the end, John's commit history will look like this: - -.John's history after pushing to the `origin` server -image::images/small-team-3.png[John's history after pushing to the `origin` server] - -In the meantime, Jessica has created a new topic branch called `issue54`, and made three commits to that branch. -She hasn't fetched John's changes yet, so her commit history looks like this: - -.Jessica's topic branch -image::images/small-team-4.png[Jessica's topic branch] - -Suddenly, Jessica learns that John has pushed some new work to the server and she wants to take a look at it, so she can fetch all new content from the server that she does not yet have with: - -[source,console] ----- -# Jessica's Machine -$ git fetch origin -... -From jessica@githost:simplegit - fbff5bc..72bbc59 master -> origin/master ----- - -That pulls down the work John has pushed up in the meantime. -Jessica's history now looks like this: - -.Jessica's history after fetching John's changes -image::images/small-team-5.png[Jessica's history after fetching John's changes] - -Jessica thinks her topic branch is ready, but she wants to know what part of John's fetched work she has to merge into her work so that she can push. -She runs `git log` to find out: - -[source,console] ----- -$ git log --no-merges issue54..origin/master -commit 738ee872852dfaa9d6634e0dea7a324040193016 -Author: John Smith <jsmith@example.com> -Date: Fri May 29 16:01:27 2009 -0700 - - Remove invalid default value ----- - -The `issue54..origin/master` syntax is a log filter that asks Git to display only those commits that are on the latter branch (in this case `origin/master`) and that are not on the first branch (in this case `issue54`). -We'll go over this syntax in detail in <<ch07-git-tools#_commit_ranges>>. - -From the above output, we can see that there is a single commit that John has made that Jessica has not merged into her local work. -If she merges `origin/master`, that is the single commit that will modify her local work. - -Now, Jessica can merge her topic work into her `master` branch, merge John's work (`origin/master`) into her `master` branch, and then push back to the server again. - -First (having committed all of the work on her `issue54` topic branch), Jessica switches back to her `master` branch in preparation for integrating all this work: - -[source,console] ----- -$ git checkout master -Switched to branch 'master' -Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. ----- - -Jessica can merge either `origin/master` or `issue54` first -- they're both upstream, so the order doesn't matter. -The end snapshot should be identical no matter which order she chooses; only the history will be different. -She chooses to merge the `issue54` branch first: - -[source,console] ----- -$ git merge issue54 -Updating fbff5bc..4af4298 -Fast forward - README | 1 + - lib/simplegit.rb | 6 +++++- - 2 files changed, 6 insertions(+), 1 deletions(-) ----- - -No problems occur; as you can see it was a simple fast-forward merge. -Jessica now completes the local merging process by merging John's earlier fetched work that is sitting in the `origin/master` branch: - -[source,console] ----- -$ git merge origin/master -Auto-merging lib/simplegit.rb -Merge made by the 'recursive' strategy. - lib/simplegit.rb | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) ----- - -Everything merges cleanly, and Jessica's history now looks like this: - -.Jessica's history after merging John's changes -image::images/small-team-6.png[Jessica's history after merging John's changes] - -Now `origin/master` is reachable from Jessica's `master` branch, so she should be able to successfully push (assuming John hasn't pushed even more changes in the meantime): - -[source,console] ----- -$ git push origin master -... -To jessica@githost:simplegit.git - 72bbc59..8059c15 master -> master ----- - -Each developer has committed a few times and merged each other's work successfully. - -.Jessica's history after pushing all changes back to the server -image::images/small-team-7.png[Jessica's history after pushing all changes back to the server] - -That is one of the simplest workflows. -You work for a while (generally in a topic branch), and merge that work into your `master` branch when it's ready to be integrated. -When you want to share that work, you fetch and merge your `master` from `origin/master` if it has changed, and finally push to the `master` branch on the server. -The general sequence is something like this: - -.General sequence of events for a simple multiple-developer Git workflow -image::images/small-team-flow.png[General sequence of events for a simple multiple-developer Git workflow] - -==== Private Managed Team - -(((contributing, private managed team))) -In this next scenario, you'll look at contributor roles in a larger private group. -You'll learn how to work in an environment where small groups collaborate on features, after which those team-based contributions are integrated by another party. - -Let's say that John and Jessica are working together on one feature (call this "`featureA`"), while Jessica and a third developer, Josie, are working on a second (say, "`featureB`"). -In this case, the company is using a type of integration-manager workflow where the work of the individual groups is integrated only by certain engineers, and the `master` branch of the main repo can be updated only by those engineers. -In this scenario, all work is done in team-based branches and pulled together by the integrators later. - -Let's follow Jessica's workflow as she works on her two features, collaborating in parallel with two different developers in this environment. -Assuming she already has her repository cloned, she decides to work on `featureA` first. -She creates a new branch for the feature and does some work on it there: - -[source,console] ----- -# Jessica's Machine -$ git checkout -b featureA -Switched to a new branch 'featureA' -$ vim lib/simplegit.rb -$ git commit -am 'Add limit to log function' -[featureA 3300904] Add limit to log function - 1 files changed, 1 insertions(+), 1 deletions(-) ----- - -At this point, she needs to share her work with John, so she pushes her `featureA` branch commits up to the server. -Jessica doesn't have push access to the `master` branch -- only the integrators do -- so she has to push to another branch in order to collaborate with John: - -[source,console] ----- -$ git push -u origin featureA -... -To jessica@githost:simplegit.git - * [new branch] featureA -> featureA ----- - -Jessica emails John to tell him that she's pushed some work into a branch named `featureA` and he can look at it now. -While she waits for feedback from John, Jessica decides to start working on `featureB` with Josie. -To begin, she starts a new feature branch, basing it off the server's `master` branch: - -[source,console] ----- -# Jessica's Machine -$ git fetch origin -$ git checkout -b featureB origin/master -Switched to a new branch 'featureB' ----- - -Now, Jessica makes a couple of commits on the `featureB` branch: - -[source,console] ----- -$ vim lib/simplegit.rb -$ git commit -am 'Make ls-tree function recursive' -[featureB e5b0fdc] Make ls-tree function recursive - 1 files changed, 1 insertions(+), 1 deletions(-) -$ vim lib/simplegit.rb -$ git commit -am 'Add ls-files' -[featureB 8512791] Add ls-files - 1 files changed, 5 insertions(+), 0 deletions(-) ----- - -Jessica's repository now looks like this: - -.Jessica's initial commit history -image::images/managed-team-1.png[Jessica's initial commit history] - -She's ready to push her work, but gets an email from Josie that a branch with some initial "`featureB`" work on it was already pushed to the server as the `featureBee` branch. -Jessica needs to merge those changes with her own before she can push her work to the server. -Jessica first fetches Josie's changes with `git fetch`: - -[source,console] ----- -$ git fetch origin -... -From jessica@githost:simplegit - * [new branch] featureBee -> origin/featureBee ----- - -Assuming Jessica is still on her checked-out `featureB` branch, she can now merge Josie's work into that branch with `git merge`: - -[source,console] ----- -$ git merge origin/featureBee -Auto-merging lib/simplegit.rb -Merge made by the 'recursive' strategy. - lib/simplegit.rb | 4 ++++ - 1 files changed, 4 insertions(+), 0 deletions(-) ----- - -At this point, Jessica wants to push all of this merged "`featureB`" work back to the server, but she doesn't want to simply push her own `featureB` branch. -Rather, since Josie has already started an upstream `featureBee` branch, Jessica wants to push to _that_ branch, which she does with: - -[source,console] ----- -$ git push -u origin featureB:featureBee -... -To jessica@githost:simplegit.git - fba9af8..cd685d1 featureB -> featureBee ----- - -This is called a _refspec_. -See <<ch10-git-internals#_refspec>> for a more detailed discussion of Git refspecs and different things you can do with them. -Also notice the `-u` flag; this is short for `--set-upstream`, which configures the branches for easier pushing and pulling later. - -Suddenly, Jessica gets email from John, who tells her he's pushed some changes to the `featureA` branch on which they are collaborating, and he asks Jessica to take a look at them. -Again, Jessica runs a simple `git fetch` to fetch _all_ new content from the server, including (of course) John's latest work: - -[source,console] ----- -$ git fetch origin -... -From jessica@githost:simplegit - 3300904..aad881d featureA -> origin/featureA ----- - -Jessica can display the log of John's new work by comparing the content of the newly-fetched `featureA` branch with her local copy of the same branch: - -[source,console] ----- -$ git log featureA..origin/featureA -commit aad881d154acdaeb2b6b18ea0e827ed8a6d671e6 -Author: John Smith <jsmith@example.com> -Date: Fri May 29 19:57:33 2009 -0700 - - Increase log output to 30 from 25 ----- - -If Jessica likes what she sees, she can merge John's new work into her local `featureA` branch with: - -[source,console] ----- -$ git checkout featureA -Switched to branch 'featureA' -$ git merge origin/featureA -Updating 3300904..aad881d -Fast forward - lib/simplegit.rb | 10 +++++++++- -1 files changed, 9 insertions(+), 1 deletions(-) ----- - -Finally, Jessica might want to make a couple minor changes to all that merged content, so she is free to make those changes, commit them to her local `featureA` branch, and push the end result back to the server: - -[source,console] ----- -$ git commit -am 'Add small tweak to merged content' -[featureA 774b3ed] Add small tweak to merged content - 1 files changed, 1 insertions(+), 1 deletions(-) -$ git push -... -To jessica@githost:simplegit.git - 3300904..774b3ed featureA -> featureA ----- - -Jessica's commit history now looks something like this: - -.Jessica's history after committing on a feature branch -image::images/managed-team-2.png[Jessica's history after committing on a feature branch] - -At some point, Jessica, Josie, and John inform the integrators that the `featureA` and `featureBee` branches on the server are ready for integration into the mainline. -After the integrators merge these branches into the mainline, a fetch will bring down the new merge commit, making the history look like this: - -.Jessica's history after merging both her topic branches -image::images/managed-team-3.png[Jessica's history after merging both her topic branches] - -Many groups switch to Git because of this ability to have multiple teams working in parallel, merging the different lines of work late in the process. -The ability of smaller subgroups of a team to collaborate via remote branches without necessarily having to involve or impede the entire team is a huge benefit of Git. -The sequence for the workflow you saw here is something like this: - -.Basic sequence of this managed-team workflow -image::images/managed-team-flow.png[Basic sequence of this managed-team workflow] - -[[_public_project]] -==== Forked Public Project - -(((contributing, public small project))) -Contributing to public projects is a bit different. -Because you don't have the permissions to directly update branches on the project, you have to get the work to the maintainers some other way. -This first example describes contributing via forking on Git hosts that support easy forking. -Many hosting sites support this (including GitHub, BitBucket, repo.or.cz, and others), and many project maintainers expect this style of contribution. -The next section deals with projects that prefer to accept contributed patches via email. - -First, you'll probably want to clone the main repository, create a topic branch for the patch or patch series you're planning to contribute, and do your work there. -The sequence looks basically like this: - -[source,console] ----- -$ git clone <url> -$ cd project -$ git checkout -b featureA - ... work ... -$ git commit - ... work ... -$ git commit ----- - -[NOTE] -==== -You may want to use `rebase -i` to squash your work down to a single commit, or rearrange the work in the commits to make the patch easier for the maintainer to review -- see <<ch07-git-tools#_rewriting_history>> for more information about interactive rebasing. -==== - -When your branch work is finished and you're ready to contribute it back to the maintainers, go to the original project page and click the "`Fork`" button, creating your own writable fork of the project. -You then need to add this repository URL as a new remote of your local repository; in this example, let's call it `myfork`: - -[source,console] ----- -$ git remote add myfork <url> ----- - -You then need to push your new work to this repository. -It's easiest to push the topic branch you're working on to your forked repository, rather than merging that work into your `master` branch and pushing that. -The reason is that if your work isn't accepted or is cherry-picked, you don't have to rewind your `master` branch (the Git `cherry-pick` operation is covered in more detail in <<ch05-distributed-git#_rebase_cherry_pick>>). -If the maintainers `merge`, `rebase`, or `cherry-pick` your work, you'll eventually get it back via pulling from their repository anyhow. - -In any event, you can push your work with: - -[source,console] ----- -$ git push -u myfork featureA ----- - -(((git commands, request-pull))) -Once your work has been pushed to your fork of the repository, you need to notify the maintainers of the original project that you have work you'd like them to merge. -This is often called a _pull request_, and you typically generate such a request either via the website -- GitHub has its own "`Pull Request`" mechanism that we'll go over in <<ch06-github#ch06-github>> -- or you can run the `git request-pull` command and email the subsequent output to the project maintainer manually. - -The `git request-pull` command takes the base branch into which you want your topic branch pulled and the Git repository URL you want them to pull from, and produces a summary of all the changes you're asking to be pulled. -For instance, if Jessica wants to send John a pull request, and she's done two commits on the topic branch she just pushed, she can run this: - -[source,console] ----- -$ git request-pull origin/master myfork -The following changes since commit 1edee6b1d61823a2de3b09c160d7080b8d1b3a40: -Jessica Smith (1): - Create new function - -are available in the git repository at: - - https://githost/simplegit.git featureA - -Jessica Smith (2): - Add limit to log function - Increase log output to 30 from 25 - - lib/simplegit.rb | 10 +++++++++- - 1 files changed, 9 insertions(+), 1 deletions(-) ----- - -This output can be sent to the maintainer -- it tells them where the work was branched from, summarizes the commits, and identifies from where the new work is to be pulled. - -On a project for which you're not the maintainer, it's generally easier to have a branch like `master` always track `origin/master` and to do your work in topic branches that you can easily discard if they're rejected. -Having work themes isolated into topic branches also makes it easier for you to rebase your work if the tip of the main repository has moved in the meantime and your commits no longer apply cleanly. -For example, if you want to submit a second topic of work to the project, don't continue working on the topic branch you just pushed up -- start over from the main repository's `master` branch: - -[source,console] ----- -$ git checkout -b featureB origin/master - ... work ... -$ git commit -$ git push myfork featureB -$ git request-pull origin/master myfork - ... email generated request pull to maintainer ... -$ git fetch origin ----- - -Now, each of your topics is contained within a silo -- similar to a patch queue -- that you can rewrite, rebase, and modify without the topics interfering or interdepending on each other, like so: - -.Initial commit history with `featureB` work -image::images/public-small-1.png[Initial commit history with `featureB` work] - -Let's say the project maintainer has pulled in a bunch of other patches and tried your first branch, but it no longer cleanly merges. -In this case, you can try to rebase that branch on top of `origin/master`, resolve the conflicts for the maintainer, and then resubmit your changes: - -[source,console] ----- -$ git checkout featureA -$ git rebase origin/master -$ git push -f myfork featureA ----- - -This rewrites your history to now look like <<psp_b>>. - -[[psp_b]] -.Commit history after `featureA` work -image::images/public-small-2.png[Commit history after `featureA` work] - -Because you rebased the branch, you have to specify the `-f` to your push command in order to be able to replace the `featureA` branch on the server with a commit that isn't a descendant of it. -An alternative would be to push this new work to a different branch on the server (perhaps called `featureAv2`). - -Let's look at one more possible scenario: the maintainer has looked at work in your second branch and likes the concept but would like you to change an implementation detail. -You'll also take this opportunity to move the work to be based off the project's current `master` branch. -You start a new branch based off the current `origin/master` branch, squash the `featureB` changes there, resolve any conflicts, make the implementation change, and then push that as a new branch: - -(((git commands, merge, squash))) -[source,console] ----- -$ git checkout -b featureBv2 origin/master -$ git merge --squash featureB - ... change implementation ... -$ git commit -$ git push myfork featureBv2 ----- - -The `--squash` option takes all the work on the merged branch and squashes it into one changeset producing the repository state as if a real merge happened, without actually making a merge commit. -This means your future commit will have one parent only and allows you to introduce all the changes from another branch and then make more changes before recording the new commit. -Also the `--no-commit` option can be useful to delay the merge commit in case of the default merge process. - -At this point, you can notify the maintainer that you've made the requested changes, and that they can find those changes in your `featureBv2` branch. - -.Commit history after `featureBv2` work -image::images/public-small-3.png[Commit history after `featureBv2` work] - -[[_project_over_email]] -==== Public Project over Email - -(((contributing, public large project))) -Many projects have established procedures for accepting patches -- you'll need to check the specific rules for each project, because they will differ. -Since there are several older, larger projects which accept patches via a developer mailing list, we'll go over an example of that now. - -The workflow is similar to the previous use case -- you create topic branches for each patch series you work on. -The difference is how you submit them to the project. -Instead of forking the project and pushing to your own writable version, you generate email versions of each commit series and email them to the developer mailing list: - -[source,console] ----- -$ git checkout -b topicA - ... work ... -$ git commit - ... work ... -$ git commit +[Design: Tokens] Update primary blue to meet WCAG AA +[Fix: Onboarding] Correct tablet breakpoint on step 3 ---- -(((git commands, format-patch))) -Now you have two commits that you want to send to the mailing list. -You use `git format-patch` to generate the mbox-formatted files that you can email to the list -- it turns each commit into an email message with the first line of the commit message as the subject and the rest of the message plus the patch that the commit introduces as the body. -The nice thing about this is that applying a patch from an email generated with `format-patch` preserves all the commit information properly. +==== Private Small Team Workflow +tag::walkthrough[] -[source,console] ----- -$ git format-patch -M origin/master -0001-add-limit-to-log-function.patch -0002-increase-log-output-to-30-from-25.patch ----- - -The `format-patch` command prints out the names of the patch files it creates. -The `-M` switch tells Git to look for renames. -The files end up looking like this: - -[source,console] ----- -$ cat 0001-add-limit-to-log-function.patch -From 330090432754092d704da8e76ca5c05c198e71a8 Mon Sep 17 00:00:00 2001 -From: Jessica Smith <jessica@example.com> -Date: Sun, 6 Apr 2008 10:17:23 -0700 -Subject: [PATCH 1/2] Add limit to log function - -Limit log functionality to the first 20 +Sam works in a "Private Small Team." He has direct push access to the repo. His daily rhythm looks like this: ---- - lib/simplegit.rb | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) +1. **Pull latest:** Sam starts his day by pulling Nora's latest research. +2. **Work in a branch:** He branches off `main` for a specific task (e.g., `feature/onboarding-illustrations`). +3. **Commit locally:** He creates small, atomic checkpoints as he finishes each illustration. +4. **Push and Merge:** Once he's happy, he pushes his branch to the server and Nora merges it into `main`. -diff --git a/lib/simplegit.rb b/lib/simplegit.rb -index 76f47bc..f9815f1 100644 ---- a/lib/simplegit.rb -+++ b/lib/simplegit.rb -@@ -14,7 +14,7 @@ class SimpleGit - end +If Sam tries to push to `main` but Nora has already pushed her own changes, Git will reject his work with a "non-fast-forward" error. Sam must pull Nora's work, merge it locally, and then push. - def log(treeish = 'master') -- command("git log #{treeish}") -+ command("git log -n 20 #{treeish}") - end - - def ls_tree(treeish = 'master') --- -2.1.0 +[source,bash] ---- - -You can also edit these patch files to add more information for the email list that you don't want to show up in the commit message. -If you add text between the `---` line and the beginning of the patch (the `diff --git` line), the developers can read it, but that content is ignored by the patching process. - -To email this to a mailing list, you can either paste the file into your email program or send it via a command-line program. -Pasting the text often causes formatting issues, especially with "`smarter`" clients that don't preserve newlines and other whitespace appropriately. -Luckily, Git provides a tool to help you send properly formatted patches via IMAP, which may be easier for you. -We'll demonstrate how to send a patch via Gmail, which happens to be the email agent we know best; you can read detailed instructions for a number of mail programs at the end of the aforementioned `Documentation/SubmittingPatches` file in the Git source code. - -(((git commands, config)))(((email))) -First, you need to set up the imap section in your `~/.gitconfig` file. -You can set each value separately with a series of `git config` commands, or you can add them manually, but in the end your config file should look something like this: - -[source,ini] ----- -[imap] - folder = "[Gmail]/Drafts" - host = imaps://imap.gmail.com - user = user@gmail.com - pass = YX]8g76G_2^sFbd - port = 993 - sslverify = false +$ git push origin main +error: failed to push some refs to 'https://github.com/sketchspark/sketchspark' +hint: Updates were rejected because the remote contains work that you do +hint: not have locally. This is usually caused by another repository pushing... ---- -If your IMAP server doesn't use SSL, the last two lines probably aren't necessary, and the host value will be `imap://` instead of `imaps://`. -When that is set up, you can use `git imap-send` to place the patch series in the Drafts folder of the specified IMAP server: +==== Public Project Workflow +tag::walkthrough[] -[source,console] ----- -$ cat *.patch |git imap-send -Resolving imap.gmail.com... ok -Connecting to [74.125.142.109]:993... ok -Logging in... -sending 2 messages -100% (2/2) done ----- +Marcus doesn't work for SketchSpark, but he uses their design tokens for his own project. He notices a bug in the JSON file and wants to fix it. Since he doesn't have push access, he uses the **Integration-Manager** model: -At this point, you should be able to go to your Drafts folder, change the To field to the mailing list you're sending the patch to, possibly CC the maintainer or person responsible for that section, and send it off. +1. **Fork:** Marcus clicks "Fork" on GitHub to create his own copy of the `sketchspark` repo. +2. **Clone:** He clones his fork to his laptop. +3. **Fix:** He creates a branch (`fix/token-typo`), fixes the bug, and commits. +4. **Push:** He pushes his branch back to *his* fork. +5. **Pull Request:** He goes to Nora’s repo and clicks "New Pull Request," asking her to pull his fix into her project. -You can also send the patches through an SMTP server. -As before, you can set each value separately with a series of `git config` commands, or you can add them manually in the sendemail section in your `~/.gitconfig` file: - -[source,ini] ----- -[sendemail] - smtpencryption = tls - smtpserver = smtp.gmail.com - smtpuser = user@gmail.com - smtpserverport = 587 ----- - -After this is done, you can use `git send-email` to send your patches: - -[source,console] ----- -$ git send-email *.patch -0001-add-limit-to-log-function.patch -0002-increase-log-output-to-30-from-25.patch -Who should the emails appear to be from? [Jessica Smith <jessica@example.com>] -Emails will be sent from: Jessica Smith <jessica@example.com> -Who should the emails be sent to? jessica@example.com -Message-ID to be used as In-Reply-To for the first email? y ----- - -Then, Git spits out a bunch of log information looking something like this for each patch you're sending: - -[source,text] ----- -(mbox) Adding cc: Jessica Smith <jessica@example.com> from - \line 'From: Jessica Smith <jessica@example.com>' -OK. Log says: -Sendmail: /usr/sbin/sendmail -i jessica@example.com -From: Jessica Smith <jessica@example.com> -To: jessica@example.com -Subject: [PATCH 1/2] Add limit to log function -Date: Sat, 30 May 2009 13:29:15 -0700 -Message-Id: <1243715356-61726-1-git-send-email-jessica@example.com> -X-Mailer: git-send-email 1.6.2.rc1.20.g8c5b.dirty -In-Reply-To: <y> -References: <y> - -Result: OK ----- - -[TIP] -==== -For help on configuring your system and email, more tips and tricks, and a sandbox to send a trial patch via email, go to https://git-send-email.io[git-send-email.io^]. -==== +Nora reviews the request, sees it's a good fix, and merges it. Marcus has contributed to the project without Nora ever having to manage his account or permissions. ==== Summary +tag::overview[] -In this section, we covered multiple workflows, and talked about the differences between working as part of a small team on closed-source projects vs contributing to a big public project. -You know to check for white-space errors before committing, and can write a great commit message. -You learned how to format patches, and e-mail them to a developer mailing list. -Dealing with merges was also covered in the context of the different workflows. -You are now well prepared to collaborate on any project. - -Next, you'll see how to work the other side of the coin: maintaining a Git project. -You'll learn how to be a benevolent dictator or integration manager. +Whether you are Sam (internal) or Marcus (external), Git’s distributed nature ensures your work is safe, your history is readable, and your collaboration is seamless. In the next section, we’ll look at things from Nora's perspective: how she manages and integrates all these contributions. diff --git a/book/05-distributed-git/sections/distributed-workflows.asc b/book/05-distributed-git/sections/distributed-workflows.asc index b61289dc1..99f4470ad 100644 --- a/book/05-distributed-git/sections/distributed-workflows.asc +++ b/book/05-distributed-git/sections/distributed-workflows.asc @@ -1,102 +1,49 @@ === Distributed Workflows +tag::concept[] (((workflows))) -In contrast with Centralized Version Control Systems (CVCSs), the distributed nature of Git allows you to be far more flexible in how developers collaborate on projects. -In centralized systems, every developer is a node working more or less equally with a central hub. -In Git, however, every developer is potentially both a node and a hub; that is, every developer can both contribute code to other repositories and maintain a public repository on which others can base their work and which they can contribute to. -This presents a vast range of workflow possibilities for your project and/or your team, so we'll cover a few common paradigms that take advantage of this flexibility. -We'll go over the strengths and possible weaknesses of each design; you can choose a single one to use, or you can mix and match features from each. +In contrast with Centralized Version Control Systems (CVCSs), the distributed nature of Git allows you to be far more flexible in how designers collaborate on projects. In centralized systems, every team member is a node working more or less equally with a central hub. In Git, however, every designer is potentially both a node and a hub. + +This flexibility allows Nora to choose a workflow that matches the SketchSpark team's size and culture. We’ll cover a few common paradigms, from small team collaboration to large-scale open-source design systems. ==== Centralized Workflow +tag::concept[] (((workflows, centralized))) -In centralized systems, there is generally a single collaboration model -- the centralized workflow. -One central hub, or _repository_, can accept code, and everyone synchronizes their work with it. -A number of developers are nodes -- consumers of that hub -- and synchronize with that centralized location. +In this model, there is a single central hub (the "source of truth") that accepts changes. Nora, Sam, and Priya all synchronize their work with this one location. -.Centralized workflow +.Centralized workflow for the SketchSpark team image::images/centralized_workflow.png[Centralized workflow] -This means that if two developers clone from the hub and both make changes, the first developer to push their changes back up can do so with no problems. -The second developer must merge in the first one's work before pushing changes up, so as not to overwrite the first developer's changes. -This concept is as true in Git as it is in Subversion(((Subversion))) (or any CVCS), and this model works perfectly well in Git. - -If you are already comfortable with a centralized workflow in your company or team, you can easily continue using that workflow with Git. -Simply set up a single repository, and give everyone on your team push access; Git won't let users overwrite each other. - -Say John and Jessica both start working at the same time. -John finishes his change and pushes it to the server. -Then Jessica tries to push her changes, but the server rejects them. -She is told that she's trying to push non-fast-forward changes and that she won't be able to do so until she fetches and merges. -This workflow is attractive to a lot of people because it's a paradigm that many are familiar and comfortable with. - -This is also not limited to small teams. -With Git's branching model, it's possible for hundreds of developers to successfully work on a single project through dozens of branches simultaneously. +If two designers clone from the hub and both make changes, the first one to push back up succeeds. The second designer must pull and merge the first one's work before they can push. This is the model Nora uses for her core team because it's familiar, straightforward, and works perfectly for tight-knit groups with high trust and shared access. [[_integration_manager]] ==== Integration-Manager Workflow +tag::concept[] (((workflows, integration manager))) -Because Git allows you to have multiple remote repositories, it's possible to have a workflow where each developer has write access to their own public repository and read access to everyone else's. -This scenario often includes a canonical repository that represents the "`official`" project. -To contribute to that project, you create your own public clone of the project and push your changes to it. -Then, you can send a request to the maintainer of the main project to pull in your changes. -The maintainer can then add your repository as a remote, test your changes locally, merge them into their branch, and push back to their repository. -The process works as follows (see <<wfdiag_b>>): - -1. The project maintainer pushes to their public repository. -2. A contributor clones that repository and makes changes. -3. The contributor pushes to their own public copy. -4. The contributor sends the maintainer an email asking them to pull changes. -5. The maintainer adds the contributor's repository as a remote and merges locally. -6. The maintainer pushes merged changes to the main repository. - -[[wfdiag_b]] -.Integration-manager workflow +As SketchSpark gains popularity, Nora wants to allow community contributors (like Marcus) to suggest improvements to their design tokens or icons. However, she doesn't want to give every stranger direct push access to the core repo. + +In the **Integration-Manager workflow**, every contributor has their own public clone (a "fork") of the project. Marcus makes changes in his fork and then sends Nora a **Pull Request**. Nora adds Marcus's fork as a remote, tests his changes, merges them locally, and pushes the approved work back to the main repository. + +.Integration-manager workflow: Marcus contributes via a fork image::images/integration-manager.png[Integration-manager workflow] (((forking))) -This is a very common workflow with hub-based tools like GitHub or GitLab, where it's easy to fork a project and push your changes into your fork for everyone to see. -One of the main advantages of this approach is that you can continue to work, and the maintainer of the main repository can pull in your changes at any time. -Contributors don't have to wait for the project to incorporate their changes -- each party can work at their own pace. +This is the standard model for GitHub. It allows Marcus to work at his own pace without Nora having to manage his permissions. Nora acts as the "gatekeeper," ensuring only high-quality, on-brand work reaches the `main` branch. ==== Dictator and Lieutenants Workflow +tag::concept[] (((workflows, dictator and lieutenants))) -This is a variant of a multiple-repository workflow. -It's generally used by huge projects with hundreds of collaborators; one famous example is the Linux kernel. -Various integration managers are in charge of certain parts of the repository; they're called _lieutenants_. -All the lieutenants have one integration manager known as the benevolent dictator. -The benevolent dictator pushes from their directory to a reference repository from which all the collaborators need to pull. -The process works like this (see <<wfdiag_c>>): - -1. Regular developers work on their topic branch and rebase their work on top of `master`. - The `master` branch is that of the reference repository to which the dictator pushes. -2. Lieutenants merge the developers' topic branches into their `master` branch. -3. The dictator merges the lieutenants' `master` branches into the dictator's `master` branch. -4. Finally, the dictator pushes that `master` branch to the reference repository so the other developers can rebase on it. - -[[wfdiag_c]] -.Benevolent dictator workflow -image::images/benevolent-dictator.png[Benevolent dictator workflow] - -This kind of workflow isn't common, but can be useful in very big projects, or in highly hierarchical environments. -It allows the project leader (the dictator) to delegate much of the work and collect large subsets of code at multiple points before integrating them. +This variant is used by massive projects with hundreds of collaborators. In this hierarchy, several "Lieutenants" are in charge of specific parts of the project (e.g., one for Illustrations, one for Design Tokens). They integrate work from their sub-teams and then pass it up to a "Benevolent Dictator" (Nora), who does the final integration into the reference repository. -[[_patterns_for_managing_source_code_branches]] -==== Patterns for Managing Source Code Branches - -[NOTE] -==== -Martin Fowler has made a guide "Patterns for Managing Source Code Branches". -This guide covers all the common Git workflows, and explains how/when to use them. -There's also a section comparing high and low integration frequencies. +.Dictator and Lieutenants: Scaling for massive design systems +image::images/benevolent-dictator.png[Benevolent dictator workflow] -https://martinfowler.com/articles/branching-patterns.html[^] -==== +While this is overkill for Nora's small team today, it's how global design systems (like Material Design or Polaris) might manage contributions at scale. ==== Workflows Summary +tag::overview[] -These are some commonly used workflows that are possible with a distributed system like Git, but you can see that many variations are possible to suit your particular real-world workflow. -Now that you can (hopefully) determine which workflow combination may work for you, we'll cover some more specific examples of how to accomplish the main roles that make up the different flows. -In the next section, you'll learn about a few common patterns for contributing to a project. +These workflows aren't mutually exclusive—Nora uses a **Centralized** model for her daily work with Sam and Priya, and an **Integration-Manager** model for external contributors like Marcus. Now that you understand the "shapes" of collaboration, let's look at how Nora and Sam actually prepare their work for contribution. diff --git a/book/05-distributed-git/sections/maintaining.asc b/book/05-distributed-git/sections/maintaining.asc index c377bb68d..707479f2e 100644 --- a/book/05-distributed-git/sections/maintaining.asc +++ b/book/05-distributed-git/sections/maintaining.asc @@ -1,556 +1,66 @@ === Maintaining a Project +tag::concept[] (((maintaining a project))) -In addition to knowing how to contribute effectively to a project, you'll likely need to know how to maintain one. -This can consist of accepting and applying patches generated via `format-patch` and emailed to you, or integrating changes in remote branches for repositories you've added as remotes to your project. -Whether you maintain a canonical repository or want to help by verifying or approving patches, you need to know how to accept work in a way that is clearest for other contributors and sustainable by you over the long run. +In addition to contributing, Nora also has to **maintain** the SketchSpark project. This means she is responsible for reviewing, testing, and integrating the work that Sam, Priya, and Marcus send her way. ==== Working in Topic Branches +tag::procedure[] (((branches, topic))) -When you're thinking of integrating new work, it's generally a good idea to try it out in a _topic branch_ -- a temporary branch specifically made to try out that new work. -This way, it's easy to tweak a patch individually and leave it if it's not working until you have time to come back to it. -If you create a simple branch name based on the theme of the work you're going to try, such as `ruby_client` or something similarly descriptive, you can easily remember it if you have to abandon it for a while and come back later. -The maintainer of the Git project tends to namespace these branches as well -- such as `sc/ruby_client`, where `sc` is short for the person who contributed the work. -As you'll remember, you can create the branch based off your `master` branch like this: +When Nora receives a contribution—whether it's an icon set from Priya or a fix from Marcus—she never merges it directly into `main`. Instead, she creates a temporary **topic branch** to evaluate it. -[source,console] +[source,bash] ---- -$ git branch sc/ruby_client master +$ git checkout -b review/marcus-token-fix main ---- -Or, if you want to also switch to it immediately, you can use the `checkout -b` option: +This allows her to test the changes in isolation. If something is broken, she can tweak it or discard the branch entirely without ever affecting the stable project history. -[source,console] ----- -$ git checkout -b sc/ruby_client master ----- - -Now you're ready to add the contributed work that you received into this topic branch and determine if you want to merge it into your longer-term branches. - -[[_patches_from_email]] -==== Applying Patches from Email - -(((email, applying patches from))) -If you receive a patch over email that you need to integrate into your project, you need to apply the patch in your topic branch to evaluate it. -There are two ways to apply an emailed patch: with `git apply` or with `git am`. - -===== Applying a Patch with `apply` - -(((git commands, apply))) -If you received the patch from someone who generated it with `git diff` or some variation of the Unix `diff` command (which is not recommended; see the next section), you can apply it with the `git apply` command. -Assuming you saved the patch at `/tmp/patch-ruby-client.patch`, you can apply the patch like this: - -[source,console] ----- -$ git apply /tmp/patch-ruby-client.patch ----- - -This modifies the files in your working directory. -It's almost identical to running a `patch -p1` command to apply the patch, although it's more paranoid and accepts fewer fuzzy matches than patch. -It also handles file adds, deletes, and renames if they're described in the `git diff` format, which `patch` won't do. -Finally, `git apply` is an "`apply all or abort all`" model where either everything is applied or nothing is, whereas `patch` can partially apply patchfiles, leaving your working directory in a weird state. -`git apply` is overall much more conservative than `patch`. -It won't create a commit for you -- after running it, you must stage and commit the changes introduced manually. - -You can also use `git apply` to see if a patch applies cleanly before you try actually applying it -- you can run `git apply --check` with the patch: - -[source,console] ----- -$ git apply --check 0001-see-if-this-helps-the-gem.patch -error: patch failed: ticgit.gemspec:1 -error: ticgit.gemspec: patch does not apply ----- - -If there is no output, then the patch should apply cleanly. -This command also exits with a non-zero status if the check fails, so you can use it in scripts if you want. - -[[_git_am]] -===== Applying a Patch with `am` - -(((git commands, am))) -If the contributor is a Git user and was good enough to use the `format-patch` command to generate their patch, then your job is easier because the patch contains author information and a commit message for you. -If you can, encourage your contributors to use `format-patch` instead of `diff` to generate patches for you. -You should only have to use `git apply` for legacy patches and things like that. - -To apply a patch generated by `format-patch`, you use `git am` (the command is named `am` as it is used to "apply a series of patches from a mailbox"). -Technically, `git am` is built to read an mbox file, which is a simple, plain-text format for storing one or more email messages in one text file. -It looks something like this: - -[source,console] ----- -From 330090432754092d704da8e76ca5c05c198e71a8 Mon Sep 17 00:00:00 2001 -From: Jessica Smith <jessica@example.com> -Date: Sun, 6 Apr 2008 10:17:23 -0700 -Subject: [PATCH 1/2] Add limit to log function - -Limit log functionality to the first 20 ----- - -This is the beginning of the output of the `git format-patch` command that you saw in the previous section; it also represents a valid mbox email format. -If someone has emailed you the patch properly using `git send-email`, and you download that into an mbox format, then you can point `git am` to that mbox file, and it will start applying all the patches it sees. -If you run a mail client that can save several emails out in mbox format, you can save entire patch series into a file and then use `git am` to apply them one at a time. - -However, if someone uploaded a patch file generated via `git format-patch` to a ticketing system or something similar, you can save the file locally and then pass that file saved on your disk to `git am` to apply it: - -[source,console] ----- -$ git am 0001-limit-log-function.patch -Applying: Add limit to log function ----- - -You can see that it applied cleanly and automatically created the new commit for you. -The author information is taken from the email's `From` and `Date` headers, and the message of the commit is taken from the `Subject` and body (before the patch) of the email. -For example, if this patch was applied from the mbox example above, the commit generated would look something like this: - -[source,console] ----- -$ git log --pretty=fuller -1 -commit 6c5e70b984a60b3cecd395edd5b48a7575bf58e0 -Author: Jessica Smith <jessica@example.com> -AuthorDate: Sun Apr 6 10:17:23 2008 -0700 -Commit: Scott Chacon <schacon@gmail.com> -CommitDate: Thu Apr 9 09:19:06 2009 -0700 - - Add limit to log function - - Limit log functionality to the first 20 ----- - -The `Commit` information indicates the person who applied the patch and the time it was applied. -The `Author` information is the individual who originally created the patch and when it was originally created. - -But it's possible that the patch won't apply cleanly. -Perhaps your main branch has diverged too far from the branch the patch was built from, or the patch depends on another patch you haven't applied yet. -In that case, the `git am` process will fail and ask you what you want to do: - -[source,console] ----- -$ git am 0001-see-if-this-helps-the-gem.patch -Applying: See if this helps the gem -error: patch failed: ticgit.gemspec:1 -error: ticgit.gemspec: patch does not apply -Patch failed at 0001. -When you have resolved this problem run "git am --resolved". -If you would prefer to skip this patch, instead run "git am --skip". -To restore the original branch and stop patching run "git am --abort". ----- - -This command puts conflict markers in any files it has issues with, much like a conflicted merge or rebase operation. -You solve this issue much the same way -- edit the file to resolve the conflict, stage the new file, and then run `git am --resolved` to continue to the next patch: - -[source,console] ----- -$ (fix the file) -$ git add ticgit.gemspec -$ git am --resolved -Applying: See if this helps the gem ----- - -If you want Git to try a bit more intelligently to resolve the conflict, you can pass a `-3` option to it, which makes Git attempt a three-way merge. -This option isn't on by default because it doesn't work if the commit the patch says it was based on isn't in your repository. -If you do have that commit -- if the patch was based on a public commit -- then the `-3` option is generally much smarter about applying a conflicting patch: - -[source,console] ----- -$ git am -3 0001-see-if-this-helps-the-gem.patch -Applying: See if this helps the gem -error: patch failed: ticgit.gemspec:1 -error: ticgit.gemspec: patch does not apply -Using index info to reconstruct a base tree... -Falling back to patching base and 3-way merge... -No changes -- Patch already applied. ----- - -In this case, without the `-3` option the patch would have been considered as a conflict. -Since the `-3` option was used the patch applied cleanly. - -If you're applying a number of patches from an mbox, you can also run the `am` command in interactive mode, which stops at each patch it finds and asks if you want to apply it: - -[source,console] ----- -$ git am -3 -i mbox -Commit Body is: --------------------------- -See if this helps the gem --------------------------- -Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all ----- - -This is nice if you have a number of patches saved, because you can view the patch first if you don't remember what it is, or not apply the patch if you've already done so. - -When all the patches for your topic are applied and committed into your branch, you can choose whether and how to integrate them into a longer-running branch. - -[[_checking_out_remotes]] -==== Checking Out Remote Branches - -(((branches, remote))) -If your contribution came from a Git user who set up their own repository, pushed a number of changes into it, and then sent you the URL to the repository and the name of the remote branch the changes are in, you can add them as a remote and do merges locally. - -For instance, if Jessica sends you an email saying that she has a great new feature in the `ruby-client` branch of her repository, you can test it by adding the remote and checking out that branch locally: - -[source,console] ----- -$ git remote add jessica https://github.com/jessica/myproject.git -$ git fetch jessica -$ git checkout -b rubyclient jessica/ruby-client ----- - -If she emails you again later with another branch containing another great feature, you could directly `fetch` and `checkout` because you already have the remote setup. - -This is most useful if you're working with a person consistently. -If someone only has a single patch to contribute once in a while, then accepting it over email may be less time consuming than requiring everyone to run their own server and having to continually add and remove remotes to get a few patches. -You're also unlikely to want to have hundreds of remotes, each for someone who contributes only a patch or two. -However, scripts and hosted services may make this easier -- it depends largely on how you develop and how your contributors develop. - -The other advantage of this approach is that you get the history of the commits as well. -Although you may have legitimate merge issues, you know where in your history their work is based; a proper three-way merge is the default rather than having to supply a `-3` and hope the patch was generated off a public commit to which you have access. - -If you aren't working with a person consistently but still want to pull from them in this way, you can provide the URL of the remote repository to the `git pull` command. -This does a one-time pull and doesn't save the URL as a remote reference: - -[source,console] ----- -$ git pull https://github.com/onetimeguy/project -From https://github.com/onetimeguy/project - * branch HEAD -> FETCH_HEAD -Merge made by the 'recursive' strategy. ----- - -[[_what_is_introduced]] -==== Determining What Is Introduced - -(((branches, diffing))) -Now you have a topic branch that contains contributed work. -At this point, you can determine what you'd like to do with it. -This section revisits a couple of commands so you can see how you can use them to review exactly what you'll be introducing if you merge this into your main branch. - -It's often helpful to get a review of all the commits that are in this branch but that aren't in your `master` branch. -You can exclude commits in the `master` branch by adding the `--not` option before the branch name. -This does the same thing as the `master..contrib` format that we used earlier. -For example, if your contributor sends you two patches and you create a branch called `contrib` and applied those patches there, you can run this: - -[source,console] ----- -$ git log contrib --not master -commit 5b6235bd297351589efc4d73316f0a68d484f118 -Author: Scott Chacon <schacon@gmail.com> -Date: Fri Oct 24 09:53:59 2008 -0700 - - See if this helps the gem - -commit 7482e0d16d04bea79d0dba8988cc78df655f16a0 -Author: Scott Chacon <schacon@gmail.com> -Date: Mon Oct 22 19:38:36 2008 -0700 - - Update gemspec to hopefully work better ----- - -To see what changes each commit introduces, remember that you can pass the `-p` option to `git log` and it will append the diff introduced to each commit. - -To see a full diff of what would happen if you were to merge this topic branch with another branch, you may have to use a weird trick to get the correct results. -You may think to run this: - -[source,console] ----- -$ git diff master ----- - -This command gives you a diff, but it may be misleading. -If your `master` branch has moved forward since you created the topic branch from it, then you'll get seemingly strange results. -This happens because Git directly compares the snapshots of the last commit of the topic branch you're on and the snapshot of the last commit on the `master` branch. -For example, if you've added a line in a file on the `master` branch, a direct comparison of the snapshots will look like the topic branch is going to remove that line. - -If `master` is a direct ancestor of your topic branch, this isn't a problem; but if the two histories have diverged, the diff will look like you're adding all the new stuff in your topic branch and removing everything unique to the `master` branch. - -What you really want to see are the changes added to the topic branch -- the work you'll introduce if you merge this branch with `master`. -You do that by having Git compare the last commit on your topic branch with the first common ancestor it has with the `master` branch. - -Technically, you can do that by explicitly figuring out the common ancestor and then running your diff on it: - -[source,console] ----- -$ git merge-base contrib master -36c7dba2c95e6bbb78dfa822519ecfec6e1ca649 -$ git diff 36c7db ----- - -or, more concisely: - -[source,console] ----- -$ git diff $(git merge-base contrib master) ----- - -However, neither of those is particularly convenient, so Git provides another shorthand for doing the same thing: the triple-dot syntax. -In the context of the `git diff` command, you can put three periods after another branch to do a `diff` between the last commit of the branch you're on and its common ancestor with another branch: - -[source,console] ----- -$ git diff master...contrib ----- - -This command shows you only the work your current topic branch has introduced since its common ancestor with `master`. -That is a very useful syntax to remember. - -==== Integrating Contributed Work +==== Integrating Work +tag::concept[] (((integrating work))) -When all the work in your topic branch is ready to be integrated into a more mainline branch, the question is how to do it. -Furthermore, what overall workflow do you want to use to maintain your project? -You have a number of choices, so we'll cover a few of them. - -===== Merging Workflows - -(((workflows, merging))) -One basic workflow is to simply merge all that work directly into your `master` branch. -In this scenario, you have a `master` branch that contains basically stable code. -When you have work in a topic branch that you think you've completed, or work that someone else has contributed and you've verified, you merge it into your master branch, delete that just-merged topic branch, and repeat. - -For instance, if we have a repository with work in two branches named `ruby_client` and `php_client` that looks like <<merwf_a>>, and we merge `ruby_client` followed by `php_client`, your history will end up looking like <<merwf_b>>. - -[[merwf_a]] -.History with several topic branches -image::images/merging-workflows-1.png[History with several topic branches] - -[[merwf_b]] -.After a topic branch merge -image::images/merging-workflows-2.png[After a topic branch merge] - -That is probably the simplest workflow, but it can possibly be problematic if you're dealing with larger or more stable projects where you want to be really careful about what you introduce. - -If you have a more important project, you might want to use a two-phase merge cycle. -In this scenario, you have two long-running branches, `master` and `develop`, in which you determine that `master` is updated only when a very stable release is cut and all new code is integrated into the `develop` branch. -You regularly push both of these branches to the public repository. -Each time you have a new topic branch to merge in (<<merwf_c>>), you merge it into `develop` (<<merwf_d>>); then, when you tag a release, you fast-forward `master` to wherever the now-stable `develop` branch is (<<merwf_e>>). +Once Nora is happy with the work in a topic branch, she has to decide how to integrate it. She has two main choices: -[[merwf_c]] -.Before a topic branch merge -image::images/merging-workflows-3.png[Before a topic branch merge] +* **Merging:** The simplest way. It creates a "merge commit" that clearly shows when the feature was brought in. This is Nora's default choice for large features from Sam or Priya. +* **Rebasing/Cherry-Picking:** If Nora wants to keep a perfectly linear history, she can rebase the work or "cherry-pick" a single commit. This is great for small fixes from external contributors like Marcus, making it look like the fix was always part of the project's natural progression. -[[merwf_d]] -.After a topic branch merge -image::images/merging-workflows-4.png[After a topic branch merge] +==== Tagging Milestones +tag::procedure[] -[[merwf_e]] -.After a project release -image::images/merging-workflows-5.png[After a project release] +(((tags))) +When SketchSpark reaches a major milestone—like the first time the AI model successfully generates a mobile layout—Nora marks it with a **tag**. -This way, when people clone your project's repository, they can either check out `master` to build the latest stable version and keep up to date on that easily, or they can check out `develop`, which is the more cutting-edge content. -You can also extend this concept by having an `integrate` branch where all the work is merged together. -Then, when the codebase on that branch is stable and passes tests, you merge it into a `develop` branch; and when that has proven itself stable for a while, you fast-forward your `master` branch. - -===== Large-Merging Workflows - -(((workflows, "merging (large)"))) -The Git project has four long-running branches: `master`, `next`, and `seen` (formerly 'pu' -- proposed updates) for new work, and `maint` for maintenance backports. -When new work is introduced by contributors, it's collected into topic branches in the maintainer's repository in a manner similar to what we've described (see <<merwf_f>>). -At this point, the topics are evaluated to determine whether they're safe and ready for consumption or whether they need more work. -If they're safe, they're merged into `next`, and that branch is pushed up so everyone can try the topics integrated together. - -[[merwf_f]] -.Managing a complex series of parallel contributed topic branches -image::images/large-merges-1.png[Managing a complex series of parallel contributed topic branches] - -If the topics still need work, they're merged into `seen` instead. -When it's determined that they're totally stable, the topics are re-merged into `master`. -The `next` and `seen` branches are then rebuilt from the `master`. -This means `master` almost always moves forward, `next` is rebased occasionally, and `seen` is rebased even more often: - -.Merging contributed topic branches into long-term integration branches -image::images/large-merges-2.png[Merging contributed topic branches into long-term integration branches] - -When a topic branch has finally been merged into `master`, it's removed from the repository. -The Git project also has a `maint` branch that is forked off from the last release to provide backported patches in case a maintenance release is required. -Thus, when you clone the Git repository, you have four branches that you can check out to evaluate the project in different stages of development, depending on how cutting edge you want to be or how you want to contribute; and the maintainer has a structured workflow to help them vet new contributions. -The Git project's workflow is specialized. -To clearly understand this you could check out the https://github.com/git/git/blob/master/Documentation/howto/maintain-git.txt[Git Maintainer's guide^]. - -[[_rebase_cherry_pick]] -===== Rebasing and Cherry-Picking Workflows - -(((workflows, rebasing and cherry-picking))) -Other maintainers prefer to rebase or cherry-pick contributed work on top of their `master` branch, rather than merging it in, to keep a mostly linear history. -When you have work in a topic branch and have determined that you want to integrate it, you move to that branch and run the rebase command to rebuild the changes on top of your current `master` (or `develop`, and so on) branch. -If that works well, you can fast-forward your `master` branch, and you'll end up with a linear project history. - -(((git commands, cherry-pick))) -The other way to move introduced work from one branch to another is to cherry-pick it. -A cherry-pick in Git is like a rebase for a single commit. -It takes the patch that was introduced in a commit and tries to reapply it on the branch you're currently on. -This is useful if you have a number of commits on a topic branch and you want to integrate only one of them, or if you only have one commit on a topic branch and you'd prefer to cherry-pick it rather than run rebase. -For example, suppose you have a project that looks like this: - -.Example history before a cherry-pick -image::images/rebasing-1.png[Example history before a cherry-pick] - -If you want to pull commit `e43a6` into your `master` branch, you can run: - -[source,console] +[source,bash] ---- -$ git cherry-pick e43a6 -Finished one cherry-pick. -[master]: created a0a41a9: "More friendly message when locking the index fails." - 3 files changed, 17 insertions(+), 3 deletions(-) +$ git tag -a v0.5-alpha -m "First end-to-end AI pipeline working" +$ git push origin v0.5-alpha ---- -This pulls the same change introduced in `e43a6`, but you get a new commit SHA-1 value, because the date applied is different. -Now your history looks like this: - -.History after cherry-picking a commit on a topic branch -image::images/rebasing-2.png[History after cherry-picking a commit on a topic branch] - -Now you can remove your topic branch and drop the commits you didn't want to pull in. - -===== Rerere - -(((git commands, rerere)))(((rerere))) -If you're doing lots of merging and rebasing, or you're maintaining a long-lived topic branch, Git has a feature called "`rerere`" that can help. - -Rerere stands for "`reuse recorded resolution`" -- it's a way of shortcutting manual conflict resolution. -When rerere is enabled, Git will keep a set of pre- and post-images from successful merges, and if it notices that there's a conflict that looks exactly like one you've already fixed, it'll just use the fix from last time, without bothering you with it. - -This feature comes in two parts: a configuration setting and a command. -The configuration setting is `rerere.enabled`, and it's handy enough to put in your global config: - -[source,console] ----- -$ git config --global rerere.enabled true ----- +This tag acts as a permanent bookmark. If the team ever needs to go back and see exactly what the "Alpha" version looked like, they can do so in seconds. -Now, whenever you do a merge that resolves conflicts, the resolution will be recorded in the cache in case you need it in the future. +==== Generating Reports +tag::reference[] -If you need to, you can interact with the rerere cache using the `git rerere` command. -When it's invoked alone, Git checks its database of resolutions and tries to find a match with any current merge conflicts and resolve them (although this is done automatically if `rerere.enabled` is set to `true`). -There are also subcommands to see what will be recorded, to erase specific resolution from the cache, and to clear the entire cache. -We will cover rerere in more detail in <<ch07-git-tools#ref_rerere>>. - -[[_tagging_releases]] -==== Tagging Your Releases - -(((tags)))(((tags, signing))) -When you've decided to cut a release, you'll probably want to assign a tag so you can re-create that release at any point going forward. -You can create a new tag as discussed in <<ch02-git-basics-chapter#ch02-git-basics-chapter>>. -If you decide to sign the tag as the maintainer, the tagging may look something like this: - -[source,console] ----- -$ git tag -s v1.5 -m 'my signed 1.5 tag' -You need a passphrase to unlock the secret key for -user: "Scott Chacon <schacon@gmail.com>" -1024-bit DSA key, ID F721C45A, created 2009-02-09 ----- - -If you do sign your tags, you may have the problem of distributing the public PGP key used to sign your tags. -The maintainer of the Git project has solved this issue by including their public key as a blob in the repository and then adding a tag that points directly to that content. -To do this, you can figure out which key you want by running `gpg --list-keys`: - -[source,console] ----- -$ gpg --list-keys -/Users/schacon/.gnupg/pubring.gpg ---------------------------------- -pub 1024D/F721C45A 2009-02-09 [expires: 2010-02-09] -uid Scott Chacon <schacon@gmail.com> -sub 2048g/45D02282 2009-02-09 [expires: 2010-02-09] ----- - -Then, you can directly import the key into the Git database by exporting it and piping that through `git hash-object`, which writes a new blob with those contents into Git and gives you back the SHA-1 of the blob: - -[source,console] ----- -$ gpg -a --export F721C45A | git hash-object -w --stdin -659ef797d181633c87ec71ac3f9ba29fe5775b92 ----- - -Now that you have the contents of your key in Git, you can create a tag that points directly to it by specifying the new SHA-1 value that the `hash-object` command gave you: - -[source,console] ----- -$ git tag -a maintainer-pgp-pub 659ef797d181633c87ec71ac3f9ba29fe5775b92 ----- - -If you run `git push --tags`, the `maintainer-pgp-pub` tag will be shared with everyone. -If anyone wants to verify a tag, they can directly import your PGP key by pulling the blob directly out of the database and importing it into GPG: - -[source,console] ----- -$ git show maintainer-pgp-pub | gpg --import ----- - -They can use that key to verify all your signed tags. -Also, if you include instructions in the tag message, running `git show <tag>` will let you give the end user more specific instructions about tag verification. - -[[_build_number]] -==== Generating a Build Number - -(((build numbers)))(((git commands, describe))) -Because Git doesn't have monotonically increasing numbers like 'v123' or the equivalent to go with each commit, if you want to have a human-readable name to go with a commit, you can run `git describe` on that commit. -In response, Git generates a string consisting of the name of the most recent tag earlier than that commit, followed by the number of commits since that tag, followed finally by a partial SHA-1 value of the commit being described (prefixed with the letter "g" meaning Git): - -[source,console] ----- -$ git describe master -v1.6.2-rc1-20-g8c5b85c ----- - -This way, you can export a snapshot or build and name it something understandable to people. -In fact, if you build Git from source code cloned from the Git repository, `git --version` gives you something that looks like this. -If you're describing a commit that you have directly tagged, it gives you simply the tag name. - -By default, the `git describe` command requires annotated tags (tags created with the `-a` or `-s` flag); if you want to take advantage of lightweight (non-annotated) tags as well, add the `--tags` option to the command. -You can also use this string as the target of a `git checkout` or `git show` command, although it relies on the abbreviated SHA-1 value at the end, so it may not be valid forever. -For instance, the Linux kernel recently jumped from 8 to 10 characters to ensure SHA-1 object uniqueness, so older `git describe` output names were invalidated. - -[[_preparing_release]] -==== Preparing a Release - -(((releasing)))(((git commands, archive))) -Now you want to release a build. -One of the things you'll want to do is create an archive of the latest snapshot of your code for those poor souls who don't use Git. -The command to do this is `git archive`: +(((git commands, shortlog))) +Before the team's weekly design sync, Nora uses the `git shortlog` command to see a summary of everyone's contributions: -[source,console] ----- -$ git archive master --prefix='project/' | gzip > `git describe master`.tar.gz -$ ls *.tar.gz -v1.6.2-rc1-20-g8c5b85c.tar.gz +[source,bash] ---- +$ git shortlog --no-merges main --since="1 week ago" +Nora UX (3): + [Research: Persona] Update early-adopter goals + [Research: Product] Refine vision statement -If someone opens that tarball, they get the latest snapshot of your project under a `project` directory. -You can also create a zip archive in much the same way, but by passing the `--format=zip` option to `git archive`: - -[source,console] +Sam UI (2): + [Design: Results] Add initial grid layout + [Design: Tokens] Update primary blue palette ---- -$ git archive master --prefix='project/' --format=zip > `git describe master`.zip ----- - -You now have a nice tarball and a zip archive of your project release that you can upload to your website or email to people. -[[_the_shortlog]] -==== The Shortlog +This gives Nora a clean, human-readable list of everything that has happened in the SketchSpark project over the last week. -(((git commands, shortlog))) -It's time to email your mailing list of people who want to know what's happening in your project. -A nice way of quickly getting a sort of changelog of what has been added to your project since your last release or email is to use the `git shortlog` command. -It summarizes all the commits in the range you give it; for example, the following gives you a summary of all the commits since your last release, if your last release was named `v1.0.1`: - -[source,console] ----- -$ git shortlog --no-merges master --not v1.0.1 -Chris Wanstrath (6): - Add support for annotated tags to Grit::Tag - Add packed-refs annotated tag support. - Add Grit::Commit#to_patch - Update version and History.txt - Remove stray `puts` - Make ls_tree ignore nils - -Tom Preston-Werner (4): - fix dates in history - dynamic version method - Version bump to 1.0.2 - Regenerated gemspec for version 1.0.2 ----- +==== Summary +tag::overview[] -You get a clean summary of all the commits since `v1.0.1`, grouped by author, that you can email to your list. +Maintaining a project is about more than just managing files; it’s about protecting the **integrity** of the design. By using topic branches, thoughtful integration, and clear tagging, Nora ensures that SketchSpark remains organized, stable, and ready for its next big launch. diff --git a/book/06-github/sections/1-setting-up-account.asc b/book/06-github/sections/1-setting-up-account.asc index 2ab023ec0..c49a436d1 100644 --- a/book/06-github/sections/1-setting-up-account.asc +++ b/book/06-github/sections/1-setting-up-account.asc @@ -1,97 +1,36 @@ === Account Setup and Configuration +tag::procedure[] (((GitHub, user accounts))) -The first thing you need to do is set up a free user account. -Simply visit https://github.com[^], choose a user name that isn't already taken, provide an email address and a password, and click the big green "`Sign up for GitHub`" button. +The first thing Nora needs to do is set up a free user account. This will be her "identity" in the global design community. Simply visit https://github.com[^], choose a username (she picks `nora-ux`), provide her work email, and create a password. -.The GitHub sign-up form -image::images/signup.png[The GitHub sign-up form] - -The next thing you'll see is the pricing page for upgraded plans, but it's safe to ignore this for now. -GitHub will send you an email to verify the address you provided. -Go ahead and do this; it's pretty important (as we'll see later). - -[NOTE] -==== -GitHub provides almost all of its functionality with free accounts, except some advanced features. - -GitHub's paid plans include advanced tools and features as well as increased limits for free services, but we won't be covering those in this book. -To get more information about available plans and their comparison, visit https://github.com/pricing[^]. -==== - -Clicking the Octocat logo at the top-left of the screen will take you to your dashboard page. -You're now ready to use GitHub. +GitHub will send a verification email. It’s important to click that link—GitHub uses verified emails to link your commits to your profile, ensuring Nora gets credit for her research checkpoints. ==== SSH Access +tag::procedure[] (((SSH keys, with GitHub))) -As of right now, you're fully able to connect with Git repositories using the `https://` protocol, authenticating with the username and password you just set up. -However, to simply clone public projects, you don't even need to sign up - the account we just created comes into play when we fork projects and push to our forks a bit later. - -If you'd like to use SSH remotes, you'll need to configure a public key. -If you don't already have one, see <<ch04-git-on-the-server#_generate_ssh_key>>. -Open up your account settings using the link at the top-right of the window: +As we saw in <<ch04-git-on-the-server#ch04-git-on-the-server>>, Sam already generated an SSH key on his laptop. To use that key with GitHub, he needs to "register" it with his account. -.The "`Account settings`" link -image::images/account-settings.png[The “Account settings” link] +1. Sam logs into GitHub and clicks his avatar in the top-right corner to open **Settings**. +2. He selects **SSH and GPG keys** from the sidebar. +3. He clicks **New SSH key**. +4. He gives it a descriptive name (like "Sam's Work MacBook") and pastes the contents of his `~/.ssh/id_rsa.pub` file into the box. -Then select the "`SSH keys`" section along the left-hand side. +Once he clicks **Add SSH key**, Sam can push and pull from the SketchSpark repo securely without ever typing his password. -.The "`SSH keys`" link -image::images/ssh-keys.png[The “SSH keys” link] - -From there, click the "`Add an SSH key`" button, give your key a name, paste the contents of your `~/.ssh/id_rsa.pub` (or whatever you named it) public-key file into the text area, and click "`Add key`". - -[NOTE] -==== -Be sure to name your SSH key something you can remember. -You can name each of your keys (e.g. "My Laptop" or "Work Account") so that if you need to revoke a key later, you can easily tell which one you're looking for. -==== +==== Personalizing the Team +tag::procedure[] [[_personal_avatar]] -==== Your Avatar - -Next, if you wish, you can replace the avatar that is generated for you with an image of your choosing. -First go to the "`Profile`" tab (above the SSH Keys tab) and click "`Upload new picture`". - -.The "`Profile`" link -image::images/your-profile.png[The “Profile” link] - -We'll choose a copy of the Git logo that is on our hard drive and then we get a chance to crop it. +To make the SketchSpark repo feel professional, Nora and Sam both upload avatars. This isn't just for vanity—when they review each other's work later, having a face next to a comment makes the collaboration feel more like a real-world design crit. -.Crop your uploaded avatar +.Adding a profile picture image::images/avatar-crop.png[Crop your uploaded avatar] -Now anywhere you interact on the site, people will see your avatar next to your username. - -If you happen to have uploaded an avatar to the popular Gravatar service (often used for WordPress accounts), that avatar will be used by default and you don't need to do this step. - -==== Your Email Addresses - -The way that GitHub maps your Git commits to your user is by email address. -If you use multiple email addresses in your commits and you want GitHub to link them up properly, you need to add all the email addresses you have used to the Emails section of the admin section. - -[[_add_email_addresses]] -.Add all your email addresses -image::images/email-settings.png[Add all your email addresses] - -In <<_add_email_addresses>> we can see some of the different states that are possible. -The top address is verified and set as the primary address, meaning that is where you'll get any notifications and receipts. -The second address is verified and so can be set as the primary if you wish to switch them. -The final address is unverified, meaning that you can't make it your primary address. -If GitHub sees any of these in commit messages in any repository on the site, it will be linked to your user now. - -==== Two Factor Authentication - -Finally, for extra security, you should definitely set up Two-factor Authentication or "`2FA`". -Two-factor Authentication is an authentication mechanism that is becoming more and more popular recently to mitigate the risk of your account being compromised if your password is stolen somehow. -Turning it on will make GitHub ask you for two different methods of authentication, so that if one of them is compromised, an attacker will not be able to access your account. - -You can find the Two-factor Authentication setup under the Security tab of your Account settings. - -.2FA in the Security Tab -image::images/2fa-1.png[2FA in the Security Tab] +==== Security: Two-Factor Authentication (2FA) +tag::config[] -If you click on the "`Set up two-factor authentication`" button, it will take you to a configuration page where you can choose to use a phone app to generate your secondary code (a "`time based one-time password`"), or you can have GitHub send you a code via SMS each time you need to log in. +Because the SketchSpark repository contains proprietary research and upcoming UI designs, Nora mandates that everyone on the team enables **Two-Factor Authentication (2FA)**. This adds a second layer of security (like a code on your phone) so that even if someone steals Sam’s password, they can't access the design assets. -After you choose which method you prefer and follow the instructions for setting up 2FA, your account will then be a little more secure and you will have to provide a code in addition to your password whenever you log into GitHub. +You can find the 2FA setup under the **Password and authentication** tab in your GitHub settings. Nora prefers using a mobile app like 1Password or Authy for the codes. diff --git a/book/06-github/sections/2-contributing.asc b/book/06-github/sections/2-contributing.asc index 1dffbd9a5..4d939de66 100644 --- a/book/06-github/sections/2-contributing.asc +++ b/book/06-github/sections/2-contributing.asc @@ -1,548 +1,63 @@ === Contributing to a Project +tag::concept[] -Now that our account is set up, let's walk through some details that could be useful in helping you contribute to an existing project. +Now that Nora and Sam have their accounts, let's walk through how they actually use GitHub to collaborate. While they both have push access to the main `sketchspark` repo, they follow a process called the **GitHub Flow** to ensure all design changes are reviewed before being finalized. ==== Forking Projects +tag::concept[] (((forking))) -If you want to contribute to an existing project to which you don't have push access, you can "`fork`" the project. -When you "`fork`" a project, GitHub will make a copy of the project that is entirely yours; it lives in your namespace, and you can push to it. +As we mentioned in Chapter 5, external contributors like Marcus use **forking**. When Marcus "forks" the SketchSpark project, GitHub creates an identical copy of Nora's repo under Marcus's own namespace (`marcus-design/sketchspark`). -[NOTE] -==== -Historically, the term "`fork`" has been somewhat negative in context, meaning that someone took an open source project in a different direction, sometimes creating a competing project and splitting the contributors. -In GitHub, a "`fork`" is simply the same project in your own namespace, allowing you to make changes to a project publicly as a way to contribute in a more open manner. -==== +To fork, Marcus simply clicks the **Fork** button at the top-right of Nora's project page. -This way, projects don't have to worry about adding users as collaborators to give them push access. -People can fork a project, push to it, and contribute their changes back to the original repository by creating what's called a Pull Request, which we'll cover next. -This opens up a discussion thread with code review, and the owner and the contributor can then communicate about the change until the owner is happy with it, at which point the owner can merge it in. +.The Fork button: creating your own sandbox +image::images/forkbutton.png[The Fork button] -To fork a project, visit the project page and click the "`Fork`" button at the top-right of the page. - -.The "`Fork`" button -image::images/forkbutton.png[The “Fork” button] - -After a few seconds, you'll be taken to your new project page, with your own writeable copy of the code. +Now Marcus has a writable copy where he can experiment with new icon styles. When he's ready, he will contribute those changes back to Nora via a **Pull Request**. [[ch06-github_flow]] ==== The GitHub Flow +tag::concept[] (((GitHub, Flow))) -GitHub is designed around a particular collaboration workflow, centered on Pull Requests. -This flow works whether you're collaborating with a tightly-knit team in a single shared repository, or a globally-distributed company or network of strangers contributing to a project through dozens of forks. -It is centered on the <<ch03-git-branching#_topic_branch>> workflow covered in <<ch03-git-branching#ch03-git-branching>>. - -Here's how it generally works: - -1. Fork the project. -2. Create a topic branch from `master`. -3. Make some commits to improve the project. -4. Push this branch to your GitHub project. -5. Open a Pull Request on GitHub. -6. Discuss, and optionally continue committing. -7. The project owner merges or closes the Pull Request. -8. Sync the updated `master` back to your fork. - -This is basically the Integration Manager workflow covered in <<ch05-distributed-git#_integration_manager>>, but instead of using email to communicate and review changes, teams use GitHub's web based tools. - -Let's walk through an example of proposing a change to an open source project hosted on GitHub using this flow. - -[TIP] -==== -You can use the official *GitHub CLI* tool instead of the GitHub web interface for most things. -The tool can be used on Windows, macOS, and Linux systems. -Go to the https://cli.github.com/[GitHub CLI homepage^] for installation instructions and the manual. -==== - -===== Creating a Pull Request - -Tony is looking for code to run on his Arduino programmable microcontroller and has found a great program file on GitHub at https://github.com/schacon/blink[^]. - -.The project we want to contribute to -image::images/blink-01-start.png[The project we want to contribute to] - -The only problem is that the blinking rate is too fast. -We think it's much nicer to wait 3 seconds instead of 1 in between each state change. -So let's improve the program and submit it back to the project as a proposed change. - -First, we click the 'Fork' button as mentioned earlier to get our own copy of the project. -Our user name here is "`tonychacon`" so our copy of this project is at `https://github.com/tonychacon/blink` and that's where we can edit it. -We will clone it locally, create a topic branch, make the code change and finally push that change back up to GitHub. - -[source,console] ----- -$ git clone https://github.com/tonychacon/blink <1> -Cloning into 'blink'... - -$ cd blink -$ git checkout -b slow-blink <2> -Switched to a new branch 'slow-blink' - -$ sed -i '' 's/1000/3000/' blink.ino (macOS) <3> -# If you're on a Linux system, do this instead: -# $ sed -i 's/1000/3000/' blink.ino <3> - -$ git diff --word-diff <4> -diff --git a/blink.ino b/blink.ino -index 15b9911..a6cc5a5 100644 ---- a/blink.ino -+++ b/blink.ino -@@ -18,7 +18,7 @@ void setup() { -// the loop routine runs over and over again forever: -void loop() { - digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) - [-delay(1000);-]{+delay(3000);+} // wait for a second - digitalWrite(led, LOW); // turn the LED off by making the voltage LOW - [-delay(1000);-]{+delay(3000);+} // wait for a second -} - -$ git commit -a -m 'Change delay to 3 seconds' <5> -[slow-blink 5ca509d] Change delay to 3 seconds - 1 file changed, 2 insertions(+), 2 deletions(-) - -$ git push origin slow-blink <6> -Username for 'https://github.com': tonychacon -Password for 'https://tonychacon@github.com': -Counting objects: 5, done. -Delta compression using up to 8 threads. -Compressing objects: 100% (3/3), done. -Writing objects: 100% (3/3), 340 bytes | 0 bytes/s, done. -Total 3 (delta 1), reused 0 (delta 0) -To https://github.com/tonychacon/blink - * [new branch] slow-blink -> slow-blink ----- - -<1> Clone our fork of the project locally. -<2> Create a descriptive topic branch. -<3> Make our change to the code. -<4> Check that the change is good. -<5> Commit our change to the topic branch. -<6> Push our new topic branch back up to our GitHub fork. - -Now if we go back to our fork on GitHub, we can see that GitHub noticed that we pushed a new topic branch up and presents us with a big green button to check out our changes and open a Pull Request to the original project. - -You can alternatively go to the "`Branches`" page at `\https://github.com/<user>/<project>/branches` to locate your branch and open a new Pull Request from there. - -.Pull Request button -image::images/blink-02-pr.png[Pull Request button] - -(((GitHub, pull requests))) -If we click that green button, we'll see a screen that asks us to give our Pull Request a title and description. -It is almost always worthwhile to put some effort into this, since a good description helps the owner of the original project determine what you were trying to do, whether your proposed changes are correct, and whether accepting the changes would improve the original project. - -We also see a list of the commits in our topic branch that are "`ahead`" of the `master` branch (in this case, just the one) and a unified diff of all the changes that will be made should this branch get merged by the project owner. - -.Pull Request creation page -image::images/blink-03-pull-request-open.png[Pull Request creation page] - -When you hit the 'Create pull request' button on this screen, the owner of the project you forked will get a notification that someone is suggesting a change and will link to a page that has all of this information on it. - -[NOTE] -==== -Though Pull Requests are used commonly for public projects like this when the contributor has a complete change ready to be made, it's also often used in internal projects _at the beginning_ of the development cycle. -Since you can keep pushing to the topic branch even *after* the Pull Request is opened, it's often opened early and used as a way to iterate on work as a team within a context, rather than opened at the very end of the process. -==== - -===== Iterating on a Pull Request - -At this point, the project owner can look at the suggested change and merge it, reject it or comment on it. -Let's say that he likes the idea, but would prefer a slightly longer time for the light to be off than on. - -Where this conversation may take place over email in the workflows presented in <<ch05-distributed-git#ch05-distributed-git>>, on GitHub this happens online. -The project owner can review the unified diff and leave a comment by clicking on any of the lines. - -.Comment on a specific line of code in a Pull Request -image::images/blink-04-pr-comment.png[Comment on a specific line of code in a Pull Request] - -Once the maintainer makes this comment, the person who opened the Pull Request (and indeed, anyone else watching the repository) will get a notification. -We'll go over customizing this later, but if he had email notifications turned on, Tony would get an email like this: - -[[_email_notification]] -.Comments sent as email notifications -image::images/blink-04-email.png[Comments sent as email notifications] - -Anyone can also leave general comments on the Pull Request. -In <<_pr_discussion>> we can see an example of the project owner both commenting on a line of code and then leaving a general comment in the discussion section. -You can see that the code comments are brought into the conversation as well. - -[[_pr_discussion]] -.Pull Request discussion page -image::images/blink-05-general-comment.png[Pull Request discussion page] - -Now the contributor can see what they need to do in order to get their change accepted. -Luckily this is very straightforward. -Where over email you may have to re-roll your series and resubmit it to the mailing list, with GitHub you simply commit to the topic branch again and push, which will automatically update the Pull Request. -In <<_pr_final>> you can also see that the old code comment has been collapsed in the updated Pull Request, since it was made on a line that has since been changed. - -Adding commits to an existing Pull Request doesn't trigger a notification, so once Tony has pushed his corrections he decides to leave a comment to inform the project owner that he made the requested change. - -[[_pr_final]] -.Pull Request final -image::images/blink-06-final.png[Pull Request final] - -An interesting thing to notice is that if you click on the "`Files Changed`" tab on this Pull Request, you'll get the "`unified`" diff -- that is, the total aggregate difference that would be introduced to your main branch if this topic branch was merged in. -In `git diff` terms, it basically automatically shows you `git diff master...<branch>` for the branch this Pull Request is based on. -See <<ch05-distributed-git#_what_is_introduced>> for more about this type of diff. - -The other thing you'll notice is that GitHub checks to see if the Pull Request merges cleanly and provides a button to do the merge for you on the server. -This button only shows up if you have write access to the repository and a trivial merge is possible. -If you click it GitHub will perform a "`non-fast-forward`" merge, meaning that even if the merge *could* be a fast-forward, it will still create a merge commit. - -If you would prefer, you can simply pull the branch down and merge it locally. -If you merge this branch into the `master` branch and push it to GitHub, the Pull Request will automatically be closed. - -This is the basic workflow that most GitHub projects use. -Topic branches are created, Pull Requests are opened on them, a discussion ensues, possibly more work is done on the branch and eventually the request is either closed or merged. - -[NOTE] -.Not Only Forks -==== -It's important to note that you can also open a Pull Request between two branches in the same repository. -If you're working on a feature with someone and you both have write access to the project, you can push a topic branch to the repository and open a Pull Request on it to the `master` branch of that same project to initiate the code review and discussion process. -No forking necessary. -==== - -==== Advanced Pull Requests - -Now that we've covered the basics of contributing to a project on GitHub, let's cover a few interesting tips and tricks about Pull Requests so you can be more effective in using them. - -===== Pull Requests as Patches - -It's important to understand that many projects don't really think of Pull Requests as queues of perfect patches that should apply cleanly in order, as most mailing list-based projects think of patch series contributions. -Most GitHub projects think about Pull Request branches as iterative conversations around a proposed change, culminating in a unified diff that is applied by merging. - -This is an important distinction, because generally the change is suggested before the code is thought to be perfect, which is far more rare with mailing list based patch series contributions. -This enables an earlier conversation with the maintainers so that arriving at the proper solution is more of a community effort. -When code is proposed with a Pull Request and the maintainers or community suggest a change, the patch series is generally not re-rolled, but instead the difference is pushed as a new commit to the branch, moving the conversation forward with the context of the previous work intact. - -For instance, if you go back and look again at <<_pr_final>>, you'll notice that the contributor did not rebase his commit and send another Pull Request. -Instead they added new commits and pushed them to the existing branch. -This way if you go back and look at this Pull Request in the future, you can easily find all of the context of why decisions were made. -Pushing the "`Merge`" button on the site purposefully creates a merge commit that references the Pull Request so that it's easy to go back and research the original conversation if necessary. - -===== Keeping up with Upstream - -If your Pull Request becomes out of date or otherwise doesn't merge cleanly, you will want to fix it so the maintainer can easily merge it. -GitHub will test this for you and let you know at the bottom of every Pull Request if the merge is trivial or not. - -[[_pr_fail]] -.Pull Request does not merge cleanly -image::images/pr-01-fail.png[Pull Request does not merge cleanly] - -If you see something like <<_pr_fail>>, you'll want to fix your branch so that it turns green and the maintainer doesn't have to do extra work. - -You have two main options in order to do this. -You can either rebase your branch on top of whatever the target branch is (normally the `master` branch of the repository you forked), or you can merge the target branch into your branch. - -Most developers on GitHub will choose to do the latter, for the same reasons we just went over in the previous section. -What matters is the history and the final merge, so rebasing isn't getting you much other than a slightly cleaner history and in return is *far* more difficult and error prone. - -If you want to merge in the target branch to make your Pull Request mergeable, you would add the original repository as a new remote, fetch from it, merge the main branch of that repository into your topic branch, fix any issues and finally push it back up to the same branch you opened the Pull Request on. - -For example, let's say that in the "`tonychacon`" example we were using before, the original author made a change that would create a conflict in the Pull Request. -Let's go through those steps. - -[source,console] ----- -$ git remote add upstream https://github.com/schacon/blink <1> - -$ git fetch upstream <2> -remote: Counting objects: 3, done. -remote: Compressing objects: 100% (3/3), done. -Unpacking objects: 100% (3/3), done. -remote: Total 3 (delta 0), reused 0 (delta 0) -From https://github.com/schacon/blink - * [new branch] master -> upstream/master - -$ git merge upstream/master <3> -Auto-merging blink.ino -CONFLICT (content): Merge conflict in blink.ino -Automatic merge failed; fix conflicts and then commit the result. - -$ vim blink.ino <4> -$ git add blink.ino -$ git commit -[slow-blink 3c8d735] Merge remote-tracking branch 'upstream/master' \ - into slower-blink - -$ git push origin slow-blink <5> -Counting objects: 6, done. -Delta compression using up to 8 threads. -Compressing objects: 100% (6/6), done. -Writing objects: 100% (6/6), 682 bytes | 0 bytes/s, done. -Total 6 (delta 2), reused 0 (delta 0) -To https://github.com/tonychacon/blink - ef4725c..3c8d735 slower-blink -> slow-blink ----- - -<1> Add the original repository as a remote named `upstream`. -<2> Fetch the newest work from that remote. -<3> Merge the main branch of that repository into your topic branch. -<4> Fix the conflict that occurred. -<5> Push back up to the same topic branch. - -Once you do that, the Pull Request will be automatically updated and re-checked to see if it merges cleanly. - -[[_pr_merge_fix]] -.Pull Request now merges cleanly -image::images/pr-02-merge-fix.png[Pull Request now merges cleanly] - -One of the great things about Git is that you can do that continuously. -If you have a very long-running project, you can easily merge from the target branch over and over again and only have to deal with conflicts that have arisen since the last time that you merged, making the process very manageable. - -If you absolutely wish to rebase the branch to clean it up, you can certainly do so, but it is highly encouraged to not force push over the branch that the Pull Request is already opened on. -If other people have pulled it down and done more work on it, you run into all of the issues outlined in <<ch03-git-branching#_rebase_peril>>. -Instead, push the rebased branch to a new branch on GitHub and open a brand new Pull Request referencing the old one, then close the original. - -===== References - -Your next question may be "`How do I reference the old Pull Request?`". -It turns out there are many, many ways to reference other things almost anywhere you can write in GitHub. - -Let's start with how to cross-reference another Pull Request or an Issue. -All Pull Requests and Issues are assigned numbers and they are unique within the project. -For example, you can't have Pull Request +#3+ _and_ Issue +#3+. -If you want to reference any Pull Request or Issue from any other one, you can simply put `+#<num>+` in any comment or description. -You can also be more specific if the Issue or Pull request lives somewhere else; write `username#<num>` if you're referring to an Issue or Pull Request in a fork of the repository you're in, or `username/repo#<num>` to reference something in another repository. - -Let's look at an example. -Say we rebased the branch in the previous example, created a new pull request for it, and now we want to reference the old pull request from the new one. -We also want to reference an issue in the fork of the repository and an issue in a completely different project. -We can fill out the description just like <<_pr_references>>. - -[[_pr_references]] -.Cross references in a Pull Request -image::images/mentions-01-syntax.png[Cross references in a Pull Request] - -When we submit this pull request, we'll see all of that rendered like <<_pr_references_render>>. - -[[_pr_references_render]] -.Cross references rendered in a Pull Request -image::images/mentions-02-render.png[Cross references rendered in a Pull Request] - -Notice that the full GitHub URL we put in there was shortened to just the information needed. - -Now if Tony goes back and closes out the original Pull Request, we can see that by mentioning it in the new one, GitHub has automatically created a trackback event in the Pull Request timeline. -This means that anyone who visits this Pull Request and sees that it is closed can easily link back to the one that superseded it. -The link will look something like <<_pr_closed>>. - -[[_pr_closed]] -.Link back to the new Pull Request in the closed Pull Request timeline -image::images/mentions-03-closed.png[Link back to the new Pull Request in the closed Pull Request timeline] - -In addition to issue numbers, you can also reference a specific commit by SHA-1. -You have to specify a full 40 character SHA-1, but if GitHub sees that in a comment, it will link directly to the commit. -Again, you can reference commits in forks or other repositories in the same way you did with issues. - -==== GitHub Flavored Markdown - -Linking to other Issues is just the beginning of interesting things you can do with almost any text box on GitHub. -In Issue and Pull Request descriptions, comments, code comments and more, you can use what is called "`GitHub Flavored Markdown`". -Markdown is like writing in plain text but which is rendered richly. - -See <<_example_markdown>> for an example of how comments or text can be written and then rendered using Markdown. - -[[_example_markdown]] -.An example of GitHub Flavored Markdown as written and as rendered -image::images/markdown-01-example.png[An example of GitHub Flavored Markdown as written and as rendered] - -The GitHub flavor of Markdown adds more things you can do beyond the basic Markdown syntax. -These can all be really useful when creating useful Pull Request or Issue comments or descriptions. - -===== Task Lists - -The first really useful GitHub specific Markdown feature, especially for use in Pull Requests, is the Task List. -A task list is a list of checkboxes of things you want to get done. -Putting them into an Issue or Pull Request normally indicates things that you want to get done before you consider the item complete. - -You can create a task list like this: - -[source,text] ----- -- [X] Write the code -- [ ] Write all the tests -- [ ] Document the code ----- - -If we include this in the description of our Pull Request or Issue, we'll see it rendered like <<_eg_task_lists>>. - -[[_eg_task_lists]] -.Task lists rendered in a Markdown comment -image::images/markdown-02-tasks.png[Task lists rendered in a Markdown comment] - -This is often used in Pull Requests to indicate what all you would like to get done on the branch before the Pull Request will be ready to merge. -The really cool part is that you can simply click the checkboxes to update the comment -- you don't have to edit the Markdown directly to check tasks off. - -What's more, GitHub will look for task lists in your Issues and Pull Requests and show them as metadata on the pages that list them out. -For example, if you have a Pull Request with tasks and you look at the overview page of all Pull Requests, you can see how far done it is. -This helps people break down Pull Requests into subtasks and helps other people track the progress of the branch. -You can see an example of this in <<_task_list_progress>>. - -[[_task_list_progress]] -.Task list summary in the Pull Request list -image::images/markdown-03-task-summary.png[Task list summary in the Pull Request list] - -These are incredibly useful when you open a Pull Request early and use it to track your progress through the implementation of the feature. - -===== Code Snippets - -You can also add code snippets to comments. -This is especially useful if you want to present something that you _could_ try to do before actually implementing it as a commit on your branch. -This is also often used to add example code of what is not working or what this Pull Request could implement. - -To add a snippet of code you have to "`fence`" it in backticks. - -[source,text] ----- -```java -for(int i=0 ; i < 5 ; i++) -{ - System.out.println("i is : " + i); -} -``` ----- - -If you add a language name like we did there with 'java', GitHub will also try to syntax highlight the snippet. -In the case of the above example, it would end up rendering like <<_md_code>>. - -[[_md_code]] -.Rendered fenced code example -image::images/markdown-04-fenced-code.png[Rendered fenced code example] - -===== Quoting - -If you're responding to a small part of a long comment, you can selectively quote out of the other comment by preceding the lines with the `>` character. -In fact, this is so common and so useful that there is a keyboard shortcut for it. -If you highlight text in a comment that you want to directly reply to and hit the `r` key, it will quote that text in the comment box for you. - -The quotes look something like this: - -[source,text] ----- -> Whether 'tis Nobler in the mind to suffer -> The Slings and Arrows of outrageous Fortune, - -How big are these slings and in particular, these arrows? ----- - -Once rendered, the comment will look like <<_md_quote>>. - -[[_md_quote]] -.Rendered quoting example -image::images/markdown-05-quote.png[Rendered quoting example] - -===== Emoji - -Finally, you can also use emoji in your comments. -This is actually used quite extensively in comments you see on many GitHub Issues and Pull Requests. -There is even an emoji helper in GitHub. -If you are typing a comment and you start with a `:` character, an autocompleter will help you find what you're looking for. - -[[_md_emoji_auto]] -.Emoji autocompleter in action -image::images/markdown-06-emoji-complete.png[Emoji autocompleter in action] - -Emojis take the form of `:<name>:` anywhere in the comment. -For instance, you could write something like this: - -[source,text] ----- -I :eyes: that :bug: and I :cold_sweat:. - -:trophy: for :microscope: it. - -:+1: and :sparkles: on this :ship:, it's :fire::poop:! - -:clap::tada::panda_face: ----- - -When rendered, it would look something like <<_md_emoji>>. - -[[_md_emoji]] -.Heavy emoji commenting -image::images/markdown-07-emoji.png[Heavy emoji commenting] - -Not that this is incredibly useful, but it does add an element of fun and emotion to a medium that is otherwise hard to convey emotion in. - -[NOTE] -==== -There are actually quite a number of web services that make use of emoji characters these days. -A great cheat sheet to reference to find emoji that expresses what you want to say can be found at: - -https://www.webfx.com/tools/emoji-cheat-sheet/[^] -==== - -===== Images - -This isn't technically GitHub Flavored Markdown, but it is incredibly useful. -In addition to adding Markdown image links to comments, which can be difficult to find and embed URLs for, GitHub allows you to drag and drop images into text areas to embed them. - -[[_md_drag]] -.Drag and drop images to upload them and auto-embed them -image::images/markdown-08-drag-drop.png[Drag and drop images to upload them and auto-embed them] - -If you look at <<_md_drag>>, you can see a small "`Parsed as Markdown`" hint above the text area. -Clicking on that will give you a full cheat sheet of everything you can do with Markdown on GitHub. - -[[_fetch_and_push_on_different_repositories]] -==== Keep your GitHub public repository up-to-date +The "GitHub Flow" is the team's standard operating procedure. It’s built around short-lived branches and collaborative review. -Once you've forked a GitHub repository, your repository (your "fork") exists independently from the original. -In particular, when the original repository has new commits, GitHub informs you by a message like: +1. **Branch:** Sam creates a branch for his work (e.g., `option/card-layout`). +2. **Commit:** He commits his exports and notes locally. +3. **Push:** He pushes the branch to GitHub. +4. **Pull Request:** Sam opens a Pull Request (PR) to start a discussion. +5. **Review:** Nora reviews the UI and leaves comments. +6. **Merge:** Once approved, Nora merges the PR into `main`. -[source,text] ----- -This branch is 5 commits behind progit:master. ----- +==== Opening a Pull Request +tag::walkthrough[] -But your GitHub repository will never be automatically updated by GitHub; this is something that you must do yourself. -Fortunately, this is very easy to do. +(((Pull Requests, opening))) +After Sam pushes his `option/card-layout` branch, he visits the GitHub repository page. GitHub notices the new branch and shows a "Compare & pull request" button. -One possibility to do this requires no configuration. -For example, if you forked from `https://github.com/progit/progit2.git`, you can keep your `master` branch up-to-date like this: +When Sam clicks it, he's presented with a form. He gives the PR a title—`[Design: Results] Prototype new card-based grid`—and describes his goals. -[source,console] ----- -$ git checkout master <1> -$ git pull https://github.com/progit/progit2.git <2> -$ git push origin master <3> ----- +.Opening a Pull Request for design review +image::images/blink-03-pull-request-open.png[Opening a PR] -<1> If you were on another branch, return to `master`. -<2> Fetch changes from `https://github.com/progit/progit2.git` and merge them into `master`. -<3> Push your `master` branch to `origin`. +==== Reviewing and Discussing Changes +tag::walkthrough[] -This works, but it is a little tedious having to spell out the fetch URL every time. -You can automate this work with a bit of configuration: +(((Pull Requests, reviews))) +Once the PR is open, it becomes a **collaborative space**. Nora receives a notification and clicks in to see Sam's work. -[source,console] ----- -$ git remote add progit https://github.com/progit/progit2.git <1> -$ git fetch progit <2> -$ git branch --set-upstream-to=progit/master master <3> -$ git config --local remote.pushDefault origin <4> ----- +GitHub provides a "Files changed" tab where Nora can see the diff. For text files like `design-tokens.json`, she sees a line-by-line comparison. For PNGs, GitHub provides a visual diff tool that allows her to slide between the "Before" and "After" versions of the layout. -<1> Add the source repository and give it a name. - Here, I have chosen to call it `progit`. -<2> Get a reference on progit's branches, in particular `master`. -<3> Set your `master` branch to fetch from the `progit` remote. -<4> Define the default push repository to `origin`. +Nora can click on any line or any part of an image to leave a comment: "I love the rounded corners here, but let's check the contrast on the secondary text." -Once this is done, the workflow becomes much simpler: +.Conversational feedback on a PR +image::images/blink-04-pr-comment.png[PR Comment] -[source,console] ----- -$ git checkout master <1> -$ git pull <2> -$ git push <3> ----- +==== Merging the Pull Request +tag::procedure[] -<1> If you were on another branch, return to `master`. -<2> Fetch changes from `progit` and merge changes into `master`. -<3> Push your `master` branch to `origin`. +(((Pull Requests, merging))) +After a few rounds of feedback and minor tweaks from Sam, Nora is happy with the result. She clicks the big green **Merge pull request** button. -This approach can be useful, but it's not without downsides. -Git will happily do this work for you silently, but it won't warn you if you make a commit to `master`, pull from `progit`, then push to `origin` -- all of those operations are valid with this setup. -So you'll have to take care never to commit directly to `master`, since that branch effectively belongs to the upstream repository. +Sam’s work is now integrated into the `main` branch. GitHub automatically closes the PR and Nora deletes the `option/card-layout` branch from the server to keep things tidy. diff --git a/book/06-github/sections/3-maintaining.asc b/book/06-github/sections/3-maintaining.asc index 2505e86a6..867e37a3c 100644 --- a/book/06-github/sections/3-maintaining.asc +++ b/book/06-github/sections/3-maintaining.asc @@ -1,377 +1,40 @@ -[[_maintaining_gh_project]] === Maintaining a Project +tag::concept[] -Now that we're comfortable contributing to a project, let's look at the other side: creating, maintaining and administering your own project. - -==== Creating a New Repository - -Let's create a new repository to share our project code with. -Start by clicking the "`New repository`" button on the right-hand side of the dashboard, or from the `+` button in the top toolbar next to your username as seen in <<_new_repo_dropdown>>. - -.The "`Your repositories`" area -image::images/newrepo.png[The “Your repositories” area] - -[[_new_repo_dropdown]] -.The "`New repository`" dropdown -image::images/new-repo.png[The “New repository” dropdown] - -This takes you to the "`new repository`" form: - -.The "`new repository`" form -image::images/newrepoform.png[The “new repository” form] - -All you really have to do here is provide a project name; the rest of the fields are completely optional. -For now, just click the "`Create Repository`" button, and boom -- you have a new repository on GitHub, named `<user>/<project_name>`. - -Since you have no code there yet, GitHub will show you instructions for how to create a brand-new Git repository, or connect an existing Git project. -We won't belabor this here; if you need a refresher, check out <<ch02-git-basics-chapter#ch02-git-basics-chapter>>. - -Now that your project is hosted on GitHub, you can give the URL to anyone you want to share your project with. -Every project on GitHub is accessible over HTTPS as `\https://github.com/<user>/<project_name>`, and over SSH as `\git@github.com:<user>/<project_name>`. -Git can fetch from and push to both of these URLs, but they are access-controlled based on the credentials of the user connecting to them. - -[NOTE] -==== -It is often preferable to share the HTTPS based URL for a public project, since the user does not have to have a GitHub account to access it for cloning. -Users will have to have an account and an uploaded SSH key to access your project if you give them the SSH URL. -The HTTPS one is also exactly the same URL they would paste into a browser to view the project there. -==== - -==== Adding Collaborators - -If you're working with other people who you want to give commit access to, you need to add them as "`collaborators`". -If Ben, Jeff, and Louise all sign up for accounts on GitHub, and you want to give them push access to your repository, you can add them to your project. -Doing so will give them "`push`" access, which means they have both read and write access to the project and Git repository. - -Click the "`Settings`" link at the bottom of the right-hand sidebar. - -.The repository settings link -image::images/reposettingslink.png[The repository settings link] - -Then select "`Collaborators`" from the menu on the left-hand side. -Then, just type a username into the box, and click "`Add collaborator.`" -You can repeat this as many times as you like to grant access to everyone you like. -If you need to revoke access, just click the "`X`" on the right-hand side of their row. - -.The repository collaborators box -image::images/collaborators.png[The repository collaborators box] - -==== Managing Pull Requests - -Now that you have a project with some code in it and maybe even a few collaborators who also have push access, let's go over what to do when you get a Pull Request yourself. - -Pull Requests can either come from a branch in a fork of your repository or they can come from another branch in the same repository. -The only difference is that the ones in a fork are often from people where you can't push to their branch and they can't push to yours, whereas with internal Pull Requests generally both parties can access the branch. - -For these examples, let's assume you are "`tonychacon`" and you've created a new Arduino code project named "`fade`". - -[[_email_notifications]] -===== Email Notifications - -Someone comes along and makes a change to your code and sends you a Pull Request. -You should get an email notifying you about the new Pull Request and it should look something like <<_email_pr>>. - -[[_email_pr]] -.Email notification of a new Pull Request -image::images/maint-01-email.png[Email notification of a new Pull Request] - -There are a few things to notice about this email. -It will give you a small diffstat -- a list of files that have changed in the Pull Request and by how much. -It gives you a link to the Pull Request on GitHub. -It also gives you a few URLs that you can use from the command line. - -If you notice the line that says `git pull <url> patch-1`, this is a simple way to merge in a remote branch without having to add a remote. -We went over this quickly in <<ch05-distributed-git#_checking_out_remotes>>. -If you wish, you can create and switch to a topic branch and then run this command to merge in the Pull Request changes. - -The other interesting URLs are the `.diff` and `.patch` URLs, which as you may guess, provide unified diff and patch versions of the Pull Request. -You could technically merge in the Pull Request work with something like this: - -[source,console] ----- -$ curl https://github.com/tonychacon/fade/pull/1.patch | git am ----- - -===== Collaborating on the Pull Request - -As we covered in <<ch06-github#ch06-github_flow>>, you can now have a conversation with the person who opened the Pull Request. -You can comment on specific lines of code, comment on whole commits or comment on the entire Pull Request itself, using GitHub Flavored Markdown everywhere. - -Every time someone else comments on the Pull Request you will continue to get email notifications so you know there is activity happening. -They will each have a link to the Pull Request where the activity is happening and you can also directly respond to the email to comment on the Pull Request thread. - -.Responses to emails are included in the thread -image::images/maint-03-email-resp.png[Responses to emails are included in the thread] - -Once the code is in a place you like and want to merge it in, you can either pull the code down and merge it locally, either with the `git pull <url> <branch>` syntax we saw earlier, or by adding the fork as a remote and fetching and merging. - -If the merge is trivial, you can also just hit the "`Merge`" button on the GitHub site. -This will do a "`non-fast-forward`" merge, creating a merge commit even if a fast-forward merge was possible. -This means that no matter what, every time you hit the merge button, a merge commit is created. -As you can see in <<_merge_button>>, GitHub gives you all of this information if you click the hint link. - -[[_merge_button]] -.Merge button and instructions for merging a Pull Request manually -image::images/maint-02-merge.png[Merge button and instructions for merging a Pull Request manually] - -If you decide you don't want to merge it, you can also just close the Pull Request and the person who opened it will be notified. - -[[_pr_refs]] -===== Pull Request Refs - -If you're dealing with a *lot* of Pull Requests and don't want to add a bunch of remotes or do one time pulls every time, there is a neat trick that GitHub allows you to do. -This is a bit of an advanced trick and we'll go over the details of this a bit more in <<ch10-git-internals#_refspec>>, but it can be pretty useful. - -GitHub actually advertises the Pull Request branches for a repository as sort of pseudo-branches on the server. -By default you don't get them when you clone, but they are there in an obscured way and you can access them pretty easily. - -To demonstrate this, we're going to use a low-level command (often referred to as a "`plumbing`" command, which we'll read about more in <<ch10-git-internals#_plumbing_porcelain>>) called `ls-remote`. -This command is generally not used in day-to-day Git operations but it's useful to show us what references are present on the server. - -If we run this command against the "`blink`" repository we were using earlier, we will get a list of all the branches and tags and other references in the repository. - -[source,console] ----- -$ git ls-remote https://github.com/schacon/blink -10d539600d86723087810ec636870a504f4fee4d HEAD -10d539600d86723087810ec636870a504f4fee4d refs/heads/master -6a83107c62950be9453aac297bb0193fd743cd6e refs/pull/1/head -afe83c2d1a70674c9505cc1d8b7d380d5e076ed3 refs/pull/1/merge -3c8d735ee16296c242be7a9742ebfbc2665adec1 refs/pull/2/head -15c9f4f80973a2758462ab2066b6ad9fe8dcf03d refs/pull/2/merge -a5a7751a33b7e86c5e9bb07b26001bb17d775d1a refs/pull/4/head -31a45fc257e8433c8d8804e3e848cf61c9d3166c refs/pull/4/merge ----- - -Of course, if you're in your repository and you run `git ls-remote origin` or whatever remote you want to check, it will show you something similar to this. - -If the repository is on GitHub and you have any Pull Requests that have been opened, you'll get these references that are prefixed with `refs/pull/`. -These are basically branches, but since they're not under `refs/heads/` you don't get them normally when you clone or fetch from the server -- the process of fetching ignores them normally. - -There are two references per Pull Request - the one that ends in `/head` points to exactly the same commit as the last commit in the Pull Request branch. -So if someone opens a Pull Request in our repository and their branch is named `bug-fix` and it points to commit `a5a775`, then in *our* repository we will not have a `bug-fix` branch (since that's in their fork), but we _will_ have `pull/<pr#>/head` that points to `a5a775`. -This means that we can pretty easily pull down every Pull Request branch in one go without having to add a bunch of remotes. - -Now, you could do something like fetching the reference directly. - -[source,console] ----- -$ git fetch origin refs/pull/958/head -From https://github.com/libgit2/libgit2 - * branch refs/pull/958/head -> FETCH_HEAD ----- - -This tells Git, "`Connect to the `origin` remote, and download the ref named `refs/pull/958/head`.`" -Git happily obeys, and downloads everything you need to construct that ref, and puts a pointer to the commit you want under `.git/FETCH_HEAD`. -You can follow that up with `git merge FETCH_HEAD` into a branch you want to test it in, but that merge commit message looks a bit weird. -Also, if you're reviewing a *lot* of pull requests, this gets tedious. - -There's also a way to fetch _all_ of the pull requests, and keep them up to date whenever you connect to the remote. -Open up `.git/config` in your favorite editor, and look for the `origin` remote. -It should look a bit like this: - -[source,ini] ----- -[remote "origin"] - url = https://github.com/libgit2/libgit2 - fetch = +refs/heads/*:refs/remotes/origin/* ----- - -That line that begins with `fetch =` is a "`refspec.`" -It's a way of mapping names on the remote with names in your local `.git` directory. -This particular one tells Git, "the things on the remote that are under `refs/heads` should go in my local repository under `refs/remotes/origin`." -You can modify this section to add another refspec: - -[source,ini] ----- -[remote "origin"] - url = https://github.com/libgit2/libgit2.git - fetch = +refs/heads/*:refs/remotes/origin/* - fetch = +refs/pull/*/head:refs/remotes/origin/pr/* ----- - -That last line tells Git, "`All the refs that look like `refs/pull/123/head` should be stored locally like `refs/remotes/origin/pr/123`.`" -Now, if you save that file, and do a `git fetch`: - -[source,console] ----- -$ git fetch -# … - * [new ref] refs/pull/1/head -> origin/pr/1 - * [new ref] refs/pull/2/head -> origin/pr/2 - * [new ref] refs/pull/4/head -> origin/pr/4 -# … ----- - -Now all of the remote pull requests are represented locally with refs that act much like tracking branches; they're read-only, and they update when you do a fetch. -This makes it super easy to try the code from a pull request locally: - -[source,console] ----- -$ git checkout pr/2 -Checking out files: 100% (3769/3769), done. -Branch pr/2 set up to track remote branch pr/2 from origin. -Switched to a new branch 'pr/2' ----- - -The eagle-eyed among you would note the `head` on the end of the remote portion of the refspec. -There's also a `refs/pull/#/merge` ref on the GitHub side, which represents the commit that would result if you push the "`merge`" button on the site. -This can allow you to test the merge before even hitting the button. - -===== Pull Requests on Pull Requests - -Not only can you open Pull Requests that target the main or `master` branch, you can actually open a Pull Request targeting any branch in the network. -In fact, you can even target another Pull Request. - -If you see a Pull Request that is moving in the right direction and you have an idea for a change that depends on it or you're not sure is a good idea, or you just don't have push access to the target branch, you can open a Pull Request directly to it. - -When you go to open a Pull Request, there is a box at the top of the page that specifies which branch you're requesting to pull to and which you're requesting to pull from. -If you hit the "`Edit`" button at the right of that box you can change not only the branches but also which fork. - -[[_pr_targets]] -.Manually change the Pull Request target fork and branch -image::images/maint-04-target.png[Manually change the Pull Request target fork and branch] - -Here you can fairly easily specify to merge your new branch into another Pull Request or another fork of the project. +(((maintaining a project, GitHub))) +As the UX Lead, Nora’s role is to keep the SketchSpark project organized. GitHub provides a suite of administrative tools to help her manage the team's work, track tasks, and protect the project's integrity. ==== Mentions and Notifications +tag::procedure[] -GitHub also has a pretty nice notifications system built in that can come in handy when you have questions or need feedback from specific individuals or teams. - -In any comment you can start typing a `@` character and it will begin to autocomplete with the names and usernames of people who are collaborators or contributors in the project. - -.Start typing @ to mention someone -image::images/maint-05-mentions.png[Start typing @ to mention someone] - -You can also mention a user who is not in that dropdown, but often the autocompleter can make it faster. - -Once you post a comment with a user mention, that user will be notified. -This means that this can be a really effective way of pulling people into conversations rather than making them poll. -Very often in Pull Requests on GitHub people will pull in other people on their teams or in their company to review an Issue or Pull Request. - -If someone gets mentioned on a Pull Request or Issue, they will be "`subscribed`" to it and will continue getting notifications any time some activity occurs on it. -You will also be subscribed to something if you opened it, if you're watching the repository or if you comment on something. -If you no longer wish to receive notifications, there is an "`Unsubscribe`" button on the page you can click to stop receiving updates on it. - -.Unsubscribe from an Issue or Pull Request -image::images/maint-06-unsubscribe.png[Unsubscribe from an Issue or Pull Request] - -===== The Notifications Page - -When we mention "`notifications`" here with respect to GitHub, we mean a specific way that GitHub tries to get in touch with you when events happen and there are a few different ways you can configure them. -If you go to the "`Notification center`" tab from the settings page, you can see some of the options you have. - -.Notification center options -image::images/maint-07-notifications.png[Notification center options] - -The two choices are to get notifications over "`Email`" and over "`Web`" and you can choose either, neither or both for when you actively participate in things and for activity on repositories you are watching. - -====== Web Notifications - -Web notifications only exist on GitHub and you can only check them on GitHub. -If you have this option selected in your preferences and a notification is triggered for you, you will see a small blue dot over your notifications icon at the top of your screen as seen in <<_not_center>>. - -[[_not_center]] -.Notification center -image::images/maint-08-notifications-page.png[Notification center] - -If you click on that, you will see a list of all the items you have been notified about, grouped by project. -You can filter to the notifications of a specific project by clicking on its name in the left hand sidebar. -You can also acknowledge the notification by clicking the checkmark icon next to any notification, or acknowledge _all_ of the notifications in a project by clicking the checkmark at the top of the group. -There is also a mute button next to each checkmark that you can click to not receive any further notifications on that item. - -All of these tools are very useful for handling large numbers of notifications. -Many GitHub power users will simply turn off email notifications entirely and manage all of their notifications through this screen. - -====== Email Notifications - -Email notifications are the other way you can handle notifications through GitHub. -If you have this turned on you will get emails for each notification. -We saw examples of this in <<_email_notification>> and <<_email_pr>>. -The emails will also be threaded properly, which is nice if you're using a threading email client. - -There is also a fair amount of metadata embedded in the headers of the emails that GitHub sends you, which can be really helpful for setting up custom filters and rules. - -For instance, if we look at the actual email headers sent to Tony in the email shown in <<_email_pr>>, we will see the following among the information sent: - -[source,mbox] ----- -To: tonychacon/fade <fade@noreply.github.com> -Message-ID: <tonychacon/fade/pull/1@github.com> -Subject: [fade] Wait longer to see the dimming effect better (#1) -X-GitHub-Recipient: tonychacon -List-ID: tonychacon/fade <fade.tonychacon.github.com> -List-Archive: https://github.com/tonychacon/fade -List-Post: <mailto:reply+i-4XXX@reply.github.com> -List-Unsubscribe: <mailto:unsub+i-XXX@reply.github.com>,... -X-GitHub-Recipient-Address: tchacon@example.com ----- - -There are a couple of interesting things here. -If you want to highlight or re-route emails to this particular project or even Pull Request, the information in `Message-ID` gives you all the data in `<user>/<project>/<type>/<id>` format. -If this was an issue, for example, the `<type>` field would have been "`issues`" rather than "`pull`". - -The `List-Post` and `List-Unsubscribe` fields mean that if you have a mail client that understands those, you can easily post to the list or "`Unsubscribe`" from the thread. -That would be essentially the same as clicking the "`mute`" button on the web version of the notification or "`Unsubscribe`" on the Issue or Pull Request page itself. - -It's also worth noting that if you have both email and web notifications enabled and you read the email version of the notification, the web version will be marked as read as well if you have images allowed in your mail client. - -==== Special Files - -There are a couple of special files that GitHub will notice if they are present in your repository. - -==== README - -The first is the `README` file, which can be of nearly any format that GitHub recognizes as prose. -For example, it could be `README`, `README.md`, `README.asciidoc`, etc. -If GitHub sees a `README` file in your source, it will render it on the landing page of the project. - -Many teams use this file to hold all the relevant project information for someone who might be new to the repository or project. -This generally includes things like: - -* What the project is for -* How to configure and install it -* An example of how to use it or get it running -* The license that the project is offered under -* How to contribute to it - -Since GitHub will render this file, you can embed images or links in it for added ease of understanding. - -==== CONTRIBUTING - -The other special file that GitHub recognizes is the `CONTRIBUTING` file. -If you have a file named `CONTRIBUTING` with any file extension, GitHub will show <<_contrib_file>> when anyone starts opening a Pull Request. - -[[_contrib_file]] -.Opening a Pull Request when a CONTRIBUTING file exists -image::images/maint-09-contrib.png[Opening a Pull Request when a CONTRIBUTING file exists] - -The idea here is that you can specify specific things you want or don't want in a Pull Request sent to your project. -This way people may actually read the guidelines before opening the Pull Request. +GitHub's notification system helps Nora stay informed without checking the website constantly. -==== Project Administration +* **@Mentions:** If Sam has a question about a research finding, he can type `@nora-ux` in any PR comment. Nora will receive an instant notification. +* **Team Mentions:** Nora can also mention an entire group, like `@sketchspark/illustration`, to alert Priya and any other illustrators to a new request. -Generally there are not a lot of administrative things you can do with a single project, but there are a couple of items that might be of interest. +.Using @mentions to pull people into the conversation +image::images/maint-05-mentions.png[Mentions] -===== Changing the Default Branch +Nora manages her notification settings to ensure she gets emails for direct mentions but only web notifications for general project activity. This prevents her inbox from becoming a distraction. -If you are using a branch other than "`master`" as your default branch that you want people to open Pull Requests on or see by default, you can change that in your repository's settings page under the "`Options`" tab. +==== Special Files for the Team +tag::procedure[] -[[_default_branch]] -.Change the default branch for a project -image::images/maint-10-default-branch.png[Change the default branch for a project] +To make onboarding easier for new designers, Nora maintains two critical files in the root of the `sketchspark` repo: -Simply change the default branch in the dropdown and that will be the default for all major operations from then on, including which branch is checked out by default when someone clones the repository. +1. **README.md:** This is the project's "front door." It contains the product vision, links to the Figma workspace, and instructions for setting up the local design environment. GitHub renders this file on the repository's landing page. +2. **CONTRIBUTING.md:** This file outlines the team's standards—the commit message format, the branch naming convention, and the process for exporting assets. When anyone starts a new Pull Request, GitHub will show a link to these guidelines. -===== Transferring a Project +==== Branch Protection +tag::config[] -If you would like to transfer a project to another user or an organization in GitHub, there is a "`Transfer ownership`" option at the bottom of the same "`Options`" tab of your repository settings page that allows you to do this. +(((branch protection))) +Nora wants to ensure that the stable `main` branch is never broken by an accidental push or an unreviewed change. She sets up **Branch Protection** rules in the repository settings: -[[_transfer_project]] -.Transfer a project to another GitHub user or Organization -image::images/maint-11-transfer.png[Transfer a project to another GitHub user or Organization] +* **Require a pull request before merging:** This ensures that no one (not even Nora) can push directly to `main`. Every change *must* go through a PR. +* **Require approvals:** Nora mandates that at least one other team member must approve a PR before it can be merged. This ensures a second pair of eyes on every design decision. -This is helpful if you are abandoning a project and someone wants to take it over, or if your project is getting bigger and want to move it into an organization. +.Setting up branch protection for the 'main' branch +image::images/maint-10-default-branch.png[Branch protection] -Not only does this move the repository along with all its watchers and stars to another place, it also sets up a redirect from your URL to the new place. -It will also redirect clones and fetches from Git, not just web requests. +With these rules in place, Nora can rest easy knowing that the "source of truth" for SketchSpark is always stable and high-quality. diff --git a/book/06-github/sections/4-managing-organization.asc b/book/06-github/sections/4-managing-organization.asc index cdb2447ab..d46a93fad 100644 --- a/book/06-github/sections/4-managing-organization.asc +++ b/book/06-github/sections/4-managing-organization.asc @@ -1,72 +1,33 @@ -[[ch06-github_orgs]] -=== Managing an organization +=== Managing an Organization +tag::concept[] (((GitHub, organizations))) -In addition to single-user accounts, GitHub has what are called Organizations. -Like personal accounts, Organizational accounts have a namespace where all their projects exist, but many other things are different. -These accounts represent a group of people with shared ownership of projects, and there are many tools to manage subgroups of those people. -Normally these accounts are used for Open Source groups (such as "`perl`" or "`rails`") or companies (such as "`google`" or "`twitter`"). +As SketchSpark grows, it becomes too much for Nora to manage everything under her personal account. GitHub **Organizations** allow the team to have shared ownership of projects, professional branding, and sophisticated member management. ==== Organization Basics +tag::procedure[] -An organization is pretty easy to create; just click on the "`+`" icon at the top-right of any GitHub page, and select "`New organization`" from the menu. +Nora creates the `sketchspark` organization. This gives the team a single "home" where all their repositories (for research, UI, and the pipeline) can live together. -.The "`New organization`" menu item -image::images/neworg.png[The “New organization” menu item] - -First you'll need to name your organization and provide an email address for a main point of contact for the group. -Then you can invite other users to be co-owners of the account if you want to. - -Follow these steps and you'll soon be the owner of a brand-new organization. -Like personal accounts, organizations are free if everything you plan to store there will be open source. - -As an owner in an organization, when you fork a repository, you'll have the choice of forking it to your organization's namespace. -When you create new repositories you can create them either under your personal account or under any of the organizations that you are an owner in. -You also automatically "`watch`" any new repository created under these organizations. - -Just like in <<_personal_avatar>>, you can upload an avatar for your organization to personalize it a bit. -Also just like personal accounts, you have a landing page for the organization that lists all of your repositories and can be viewed by other people. - -Now let's cover some of the things that are a bit different with an organizational account. +An organization is easy to create: Nora clicks the **+** icon at the top-right of any GitHub page and selects **New organization**. Once set up, she can invite Sam, Priya, and Kai as members. ==== Teams +tag::concept[] -Organizations are associated with individual people by way of teams, which are simply a grouping of individual user accounts and repositories within the organization and what kind of access those people have in those repositories. - -For example, say your company has three repositories: `frontend`, `backend`, and `deployscripts`. -You'd want your HTML/CSS/JavaScript developers to have access to `frontend` and maybe `backend`, and your Operations people to have access to `backend` and `deployscripts`. -Teams make this easy, without having to manage the collaborators for every individual repository. +(((GitHub, teams))) +The real power of an organization is in **Teams**. Teams are groups of members that have specific access to specific repositories. -The Organization page shows you a simple dashboard of all the repositories, users and teams that are under this organization. +For example, Nora creates three teams: +* **Designers:** Nora, Sam, and Priya. They have **Read/Write** access to all design and research repos. +* **Engineers:** Kai and other developers. They have **Read-only** access to the design repos but **Read/Write** access to the `pipeline` repo. +* **Admins:** Just Nora (initially). She has **Owner** access to everything. -[[_org_page]] -.The Organization page -image::images/orgs-01-page.png[The Organization page] +.Managing teams in the SketchSpark organization +image::images/orgs-02-teams.png[Teams] -To manage your Teams, you can click on the Teams sidebar on the right hand side of the page in <<_org_page>>. -This will bring you to a page you can use to add members to the team, add repositories to the team or manage the settings and access control levels for the team. -Each team can have read only, read/write or administrative access to the repositories. -You can change that level by clicking the "`Settings`" button in <<_team_page>>. - -[[_team_page]] -.The Team page -image::images/orgs-02-teams.png[The Team page] - -When you invite someone to a team, they will get an email letting them know they've been invited. - -Additionally, team `@mentions` (such as `@acmecorp/frontend`) work much the same as they do with individual users, except that *all* members of the team are then subscribed to the thread. -This is useful if you want the attention from someone on a team, but you don't know exactly who to ask. - -A user can belong to any number of teams, so don't limit yourself to only access-control teams. -Special-interest teams like `ux`, `css`, or `refactoring` are useful for certain kinds of questions, and others like `legal` and `colorblind` for an entirely different kind. +Teams make it easy to manage permissions at scale. When a new designer joins, Nora just adds them to the "Designers" team, and they automatically get the access they need to every relevant repository. ==== Audit Log +tag::reference[] -Organizations also give owners access to all the information about what went on under the organization. -You can go to the 'Audit Log' tab and see what events have happened at an organization level, who did them and where in the world they were done. - -[[_the_audit_log]] -.The Audit log -image::images/orgs-03-audit.png[The Audit log] - -You can also filter down to specific types of events, specific places or specific people. +For security and compliance, Organizations have an **Audit Log**. Nora can use this to see exactly who changed a permission, who was invited to the team, and when someone enabled 2FA. This transparency is crucial for protecting the project's assets as the company scales. diff --git a/book/06-github/sections/5-scripting.asc b/book/06-github/sections/5-scripting.asc index c755afa17..302e4d737 100644 --- a/book/06-github/sections/5-scripting.asc +++ b/book/06-github/sections/5-scripting.asc @@ -1,301 +1,39 @@ === Scripting GitHub +tag::concept[] -So now we've covered all of the major features and workflows of GitHub, but any large group or project will have customizations they may want to make or external services they may want to integrate. +GitHub is not just a website; it’s a programmable platform. For Nora, this means she can automate the tedious parts of her job, like notifying her team of updates or generating reports for stakeholders. -Luckily for us, GitHub is really quite hackable in many ways. -In this section we'll cover how to use the GitHub hooks system and its API to make GitHub work how we want it to. +==== Webhooks +tag::procedure[] -==== Services and Hooks +(((GitHub, webhooks))) +A **webhook** allows GitHub to notify Nora's other tools whenever something happens in the repository. -The Hooks and Services section of GitHub repository administration is the easiest way to have GitHub interact with external systems. +For example, Nora sets up a webhook to alert the team’s Slack channel every time a new checkpoint is pushed to the `research` repo. +1. In the repo **Settings**, she clicks **Webhooks**. +2. She adds the URL for the team's Slack automation. +3. She selects the "Push" event. -===== Services - -First we'll take a look at Services. -Both the Hooks and Services integrations can be found in the Settings section of your repository, where we previously looked at adding Collaborators and changing the default branch of your project. -Under the "`Webhooks and Services`" tab you will see something like <<_services_hooks>>. - -[[_services_hooks]] -.Services and Hooks configuration section -image::images/scripting-01-services.png[Services and Hooks configuration section] - -There are dozens of services you can choose from, most of them integrations into other commercial and open source systems. -Most of them are for Continuous Integration services, bug and issue trackers, chat room systems and documentation systems. -We'll walk through setting up a very simple one, the Email hook. -If you choose "`email`" from the "`Add Service`" dropdown, you'll get a configuration screen like <<_service_config>>. - -[[_service_config]] -.Email service configuration -image::images/scripting-02-email-service.png[Email service configuration] - -In this case, if we hit the "`Add service`" button, the email address we specified will get an email every time someone pushes to the repository. -Services can listen for lots of different types of events, but most only listen for push events and then do something with that data. - -If there is a system you are using that you would like to integrate with GitHub, you should check here to see if there is an existing service integration available. -For example, if you're using Jenkins to run tests on your codebase, you can enable the Jenkins builtin service integration to kick off a test run every time someone pushes to your repository. - -===== Hooks - -If you need something more specific or you want to integrate with a service or site that is not included in this list, you can instead use the more generic hooks system. -GitHub repository hooks are pretty simple. -You specify a URL and GitHub will post an HTTP payload to that URL on any event you want. - -Generally the way this works is you can setup a small web service to listen for a GitHub hook payload and then do something with the data when it is received. - -To enable a hook, you click the "`Add webhook`" button in <<_services_hooks>>. -This will bring you to a page that looks like <<_web_hook>>. - -[[_web_hook]] -.Web hook configuration -image::images/scripting-03-webhook.png[Web hook configuration] - -The configuration for a web hook is pretty simple. -In most cases you simply enter a URL and a secret key and hit "`Add webhook`". -There are a few options for which events you want GitHub to send you a payload for -- the default is to only get a payload for the `push` event, when someone pushes new code to any branch of your repository. - -Let's see a small example of a web service you may set up to handle a web hook. -We'll use the Ruby web framework Sinatra since it's fairly concise and you should be able to easily see what we're doing. - -Let's say we want to get an email if a specific person pushes to a specific branch of our project modifying a specific file. -We could fairly easily do that with code like this: - -[source,ruby] ----- -require 'sinatra' -require 'json' -require 'mail' - -post '/payload' do - push = JSON.parse(request.body.read) # parse the JSON - - # gather the data we're looking for - pusher = push["pusher"]["name"] - branch = push["ref"] - - # get a list of all the files touched - files = push["commits"].map do |commit| - commit['added'] + commit['modified'] + commit['removed'] - end - files = files.flatten.uniq - - # check for our criteria - if pusher == 'schacon' && - branch == 'ref/heads/special-branch' && - files.include?('special-file.txt') - - Mail.deliver do - from 'tchacon@example.com' - to 'tchacon@example.com' - subject 'Scott Changed the File' - body "ALARM" - end - end -end ----- - -Here we're taking the JSON payload that GitHub delivers us and looking up who pushed it, what branch they pushed to and what files were touched in all the commits that were pushed. -Then we check that against our criteria and send an email if it matches. - -In order to develop and test something like this, you have a nice developer console in the same screen where you set the hook up. -You can see the last few deliveries that GitHub has tried to make for that webhook. -For each hook you can dig down into when it was delivered, if it was successful and the body and headers for both the request and the response. -This makes it incredibly easy to test and debug your hooks. - -[[_web_hook_debug]] -.Web hook debugging information -image::images/scripting-04-webhook-debug.png[Web hook debugging information] - -The other great feature of this is that you can redeliver any of the payloads to test your service easily. - -For more information on how to write webhooks and all the different event types you can listen for, go to the GitHub Developer documentation at https://docs.github.com/en/webhooks-and-events/webhooks/about-webhooks[^]. +Now, whenever Sam pushes his UI updates, the whole team sees it in Slack instantly. No more "Hey, did you push those PNGs yet?" messages. ==== The GitHub API +tag::concept[] (((GitHub, API))) -Services and hooks give you a way to receive push notifications about events that happen on your repositories, but what if you need more information about these events? -What if you need to automate something like adding collaborators or labeling issues? - -This is where the GitHub API comes in handy. -GitHub has tons of API endpoints for doing nearly anything you can do on the website in an automated fashion. -In this section we'll learn how to authenticate and connect to the API, how to comment on an issue and how to change the status of a Pull Request through the API. - -==== Basic Usage - -The most basic thing you can do is a simple GET request on an endpoint that doesn't require authentication. -This could be a user or read-only information on an open source project. -For example, if we want to know more about a user named "`schacon`", we can run something like this: - -[source,javascript] ----- -$ curl https://api.github.com/users/schacon -{ - "login": "schacon", - "id": 70, - "avatar_url": "https://avatars.githubusercontent.com/u/70", -# … - "name": "Scott Chacon", - "company": "GitHub", - "following": 19, - "created_at": "2008-01-27T17:19:28Z", - "updated_at": "2014-06-10T02:37:23Z" -} ----- +For even more control, Nora uses the **GitHub API**. This allows her to write small scripts that interact with her repository. -There are tons of endpoints like this to get information about organizations, projects, issues, commits -- just about anything you can publicly see on GitHub. -You can even use the API to render arbitrary Markdown or find a `.gitignore` template. +Suppose Nora wants to generate a weekly "Design Decision Report" for her manager. She writes a script that uses the API to fetch all commit messages from the last 7 days that start with `[Design:]`. -[source,javascript] +[source,bash] ---- -$ curl https://api.github.com/gitignore/templates/Java -{ - "name": "Java", - "source": "*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* -" -} +$ curl https://api.github.com/repos/sketchspark/ui-design/commits?since=2026-04-01 ---- -==== Commenting on an Issue - -However, if you want to do an action on the website such as comment on an Issue or Pull Request or if you want to view or interact with private content, you'll need to authenticate. - -There are several ways to authenticate. -You can use basic authentication with just your username and password, but generally it's a better idea to use a personal access token. -You can generate this from the "`Applications`" tab of your settings page. - -[[_access_token]] -.Generate your access token from the "`Applications`" tab of your settings page -image::images/scripting-05-access-token.png[Generate your access token from the “Applications” tab of your settings page] - -It will ask you which scopes you want for this token and a description. -Make sure to use a good description so you feel comfortable removing the token when your script or application is no longer used. - -GitHub will only show you the token once, so be sure to copy it. -You can now use this to authenticate in your script instead of using a username and password. -This is nice because you can limit the scope of what you want to do and the token is revocable. - -This also has the added advantage of increasing your rate limit. -Without authenticating, you will be limited to 60 requests per hour. -If you authenticate you can make up to 5,000 requests per hour. - -So let's use it to make a comment on one of our issues. -Let's say we want to leave a comment on a specific issue, Issue #6. -To do so we have to do an HTTP POST request to `repos/<user>/<repo>/issues/<num>/comments` with the token we just generated as an Authorization header. - -[source,javascript] ----- -$ curl -H "Content-Type: application/json" \ - -H "Authorization: token TOKEN" \ - --data '{"body":"A new comment, :+1:"}' \ - https://api.github.com/repos/schacon/blink/issues/6/comments -{ - "id": 58322100, - "html_url": "https://github.com/schacon/blink/issues/6#issuecomment-58322100", - ... - "user": { - "login": "tonychacon", - "id": 7874698, - "avatar_url": "https://avatars.githubusercontent.com/u/7874698?v=2", - "type": "User", - }, - "created_at": "2014-10-08T07:48:19Z", - "updated_at": "2014-10-08T07:48:19Z", - "body": "A new comment, :+1:" -} ----- - -Now if you go to that issue, you can see the comment that we just successfully posted as in <<_api_comment>>. - -[[_api_comment]] -.A comment posted from the GitHub API -image::images/scripting-06-comment.png[A comment posted from the GitHub API] - -You can use the API to do just about anything you can do on the website -- creating and setting milestones, assigning people to Issues and Pull Requests, creating and changing labels, accessing commit data, creating new commits and branches, opening, closing or merging Pull Requests, creating and editing teams, commenting on lines of code in a Pull Request, searching the site and on and on. - -==== Changing the Status of a Pull Request - -There is one final example we'll look at since it's really useful if you're working with Pull Requests. -Each commit can have one or more statuses associated with it and there is an API to add and query that status. - -Most of the Continuous Integration and testing services make use of this API to react to pushes by testing the code that was pushed, and then report back if that commit has passed all the tests. -You could also use this to check if the commit message is properly formatted, if the submitter followed all your contribution guidelines, if the commit was validly signed -- any number of things. - -Let's say you set up a webhook on your repository that hits a small web service that checks for a `Signed-off-by` string in the commit message. - -[source,ruby] ----- -require 'httparty' -require 'sinatra' -require 'json' - -post '/payload' do - push = JSON.parse(request.body.read) # parse the JSON - repo_name = push['repository']['full_name'] - - # look through each commit message - push["commits"].each do |commit| - - # look for a Signed-off-by string - if /Signed-off-by/.match commit['message'] - state = 'success' - description = 'Successfully signed off!' - else - state = 'failure' - description = 'No signoff found.' - end - - # post status to GitHub - sha = commit["id"] - status_url = "https://api.github.com/repos/#{repo_name}/statuses/#{sha}" - - status = { - "state" => state, - "description" => description, - "target_url" => "http://example.com/how-to-signoff", - "context" => "validate/signoff" - } - HTTParty.post(status_url, - :body => status.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'User-Agent' => 'tonychacon/signoff', - 'Authorization' => "token #{ENV['TOKEN']}" } - ) - end -end ----- - -Hopefully this is fairly simple to follow. -In this web hook handler we look through each commit that was just pushed, we look for the string 'Signed-off-by' in the commit message and finally we POST via HTTP to the `/repos/<user>/<repo>/statuses/<commit_sha>` API endpoint with the status. - -In this case you can send a state ('success', 'failure', 'error'), a description of what happened, a target URL the user can go to for more information and a "`context`" in case there are multiple statuses for a single commit. -For example, a testing service may provide a status and a validation service like this may also provide a status -- the "`context`" field is how they're differentiated. - -If someone opens a new Pull Request on GitHub and this hook is set up, you may see something like <<_commit_status>>. - -[[_commit_status]] -.Commit status via the API -image::images/scripting-07-status.png[Commit status via the API] - -You can now see a little green check mark next to the commit that has a "`Signed-off-by`" string in the message and a red cross through the one where the author forgot to sign off. -You can also see that the Pull Request takes the status of the last commit on the branch and warns you if it is a failure. -This is really useful if you're using this API for test results so you don't accidentally merge something where the last commit is failing tests. +The API returns a JSON list of all the work her team has done, which she can then automatically format into a beautiful PDF. -==== Octokit +==== Summary +tag::overview[] -Though we've been doing nearly everything through `curl` and simple HTTP requests in these examples, several open-source libraries exist that make this API available in a more idiomatic way. -At the time of this writing, the supported languages include Go, Objective-C, Ruby, and .NET. -Check out https://github.com/octokit[^] for more information on these, as they handle much of the HTTP for you. +Now you’re a GitHub user. You know how to create an account, manage an organization, use the GitHub Flow for design reviews, and even automate your workflow with webhooks and the API. -Hopefully these tools can help you customize and modify GitHub to work better for your specific workflows. -For complete documentation on the entire API as well as guides for common tasks, check out https://docs.github.com/[^]. +In the next chapter, we’ll move back to the terminal and look at some of the most powerful, "expert-level" tools that will truly make you a master of Git. diff --git a/book/07-git-tools/sections/interactive-staging.asc b/book/07-git-tools/sections/interactive-staging.asc index 1f7a5635d..c2792281e 100644 --- a/book/07-git-tools/sections/interactive-staging.asc +++ b/book/07-git-tools/sections/interactive-staging.asc @@ -1,204 +1,42 @@ [[_interactive_staging]] === Interactive Staging +tag::walkthrough[] -In this section, you'll look at a few interactive Git commands that can help you craft your commits to include only certain combinations and parts of files. -These tools are helpful if you modify a number of files extensively, then decide that you want those changes to be partitioned into several focused commits rather than one big messy commit. -This way, you can make sure your commits are logically separate changesets and can be reviewed easily by the developers working with you. +Suppose Sam has been in a creative flow all afternoon. He's updated the colors in `design-tokens.json`, tweaked the spacing in `screens/results/grid.css`, and fixed a typo in the `product-brief.md`. -If you run `git add` with the `-i` or `--interactive` option, Git enters an interactive shell mode, displaying something like this: +Now he wants to commit, but he realizes he has two separate "ideas" in his working directory. He wants one checkpoint for the **UI updates** and another for the **Brief correction**. In Chapter 2, we learned that he could just `git add` each file separately. But what if he had made two different changes *inside the same file*? -[source,console] ----- -$ git add -i - staged unstaged path - 1: unchanged +0/-1 TODO - 2: unchanged +1/-1 index.html - 3: unchanged +5/-1 lib/simplegit.rb - -*** Commands *** - 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked - 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp -What now> ----- - -You can see that this command shows you a much different view of your staging area than you're probably used to -- basically, the same information you get with `git status` but a bit more succinct and informative. -It lists the changes you've staged on the left and unstaged changes on the right. - -After this comes a "`Commands`" section, which allows you to do a number of things like staging and unstaging files, staging parts of files, adding untracked files, and displaying diffs of what has been staged. - -==== Staging and Unstaging Files - -If you type `u` or `2` (for update) at the `What now>` prompt, you're prompted for which files you want to stage: - -[source,console] ----- -What now> u - staged unstaged path - 1: unchanged +0/-1 TODO - 2: unchanged +1/-1 index.html - 3: unchanged +5/-1 lib/simplegit.rb -Update>> ----- - -To stage the `TODO` and `index.html` files, you can type the numbers: +This is where **Interactive Staging** (also known as "Patch Mode") is a lifesaver. -[source,console] ----- -Update>> 1,2 - staged unstaged path -* 1: unchanged +0/-1 TODO -* 2: unchanged +1/-1 index.html - 3: unchanged +5/-1 lib/simplegit.rb -Update>> ----- - -The `*` next to each file means the file is selected to be staged. -If you press Enter after typing nothing at the `Update>>` prompt, Git takes anything selected and stages it for you: - -[source,console] ----- -Update>> -updated 2 paths - -*** Commands *** - 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked - 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp -What now> s - staged unstaged path - 1: +0/-1 nothing TODO - 2: +1/-1 nothing index.html - 3: unchanged +5/-1 lib/simplegit.rb ----- - -Now you can see that the `TODO` and `index.html` files are staged and the `simplegit.rb` file is still unstaged. -If you want to unstage the `TODO` file at this point, you use the `r` or `3` (for revert) option: - -[source,console] ----- -*** Commands *** - 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked - 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp -What now> r - staged unstaged path - 1: +0/-1 nothing TODO - 2: +1/-1 nothing index.html - 3: unchanged +5/-1 lib/simplegit.rb -Revert>> 1 - staged unstaged path -* 1: +0/-1 nothing TODO - 2: +1/-1 nothing index.html - 3: unchanged +5/-1 lib/simplegit.rb -Revert>> [enter] -reverted one path ----- +==== Staging by Hunk +tag::procedure[] -Looking at your Git status again, you can see that you've unstaged the `TODO` file: +(((git commands, add, interactive))) +Sam can tell Git to walk him through every change he's made and ask if he wants to stage it. He uses the `-p` or `--patch` flag: -[source,console] +[source,bash] ---- -*** Commands *** - 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked - 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp -What now> s - staged unstaged path - 1: unchanged +0/-1 TODO - 2: +1/-1 nothing index.html - 3: unchanged +5/-1 lib/simplegit.rb +$ git add -p ---- -To see the diff of what you've staged, you can use the `d` or `6` (for diff) command. -It shows you a list of your staged files, and you can select the ones for which you would like to see the staged diff. -This is much like specifying `git diff --cached` on the command line: +Git will show Sam a "hunk" of his changes (a small block of code or text) and ask: +`Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?` -[source,console] ----- -*** Commands *** - 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked - 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp -What now> d - staged unstaged path - 1: +1/-1 nothing index.html -Review diff>> 1 -diff --git a/index.html b/index.html -index 4d07108..4335f49 100644 ---- a/index.html -+++ b/index.html -@@ -16,7 +16,7 @@ Date Finder - - <p id="out">...</p> - --<div id="footer">contact : support@github.com</div> -+<div id="footer">contact : email.support@github.com</div> - - <script type="text/javascript"> ----- - -With these basic commands, you can use the interactive add mode to deal with your staging area a little more easily. - -==== Staging Patches - -It's also possible for Git to stage certain _parts_ of files and not the rest. -For example, if you make two changes to your `simplegit.rb` file and want to stage one of them and not the other, doing so is very easy in Git. -From the same interactive prompt explained in the previous section, type `p` or `5` (for patch). -Git will ask you which files you would like to partially stage; then, for each section of the selected files, it will display hunks of the file diff and ask if you would like to stage them, one by one: - -[source,console] ----- -diff --git a/lib/simplegit.rb b/lib/simplegit.rb -index dd5ecc4..57399e0 100644 ---- a/lib/simplegit.rb -+++ b/lib/simplegit.rb -@@ -22,7 +22,7 @@ class SimpleGit - end - - def log(treeish = 'master') -- command("git log -n 25 #{treeish}") -+ command("git log -n 30 #{treeish}") - end - - def blame(path) -Stage this hunk [y,n,a,d,/,j,J,g,e,?]? ----- - -You have a lot of options at this point. -Typing `?` shows a list of what you can do: - -[source,console] ----- -Stage this hunk [y,n,a,d,/,j,J,g,e,?]? ? -y - stage this hunk -n - do not stage this hunk -a - stage this and all the remaining hunks in the file -d - do not stage this hunk nor any of the remaining hunks in the file -g - select a hunk to go to -/ - search for a hunk matching the given regex -j - leave this hunk undecided, see next undecided hunk -J - leave this hunk undecided, see next hunk -k - leave this hunk undecided, see previous undecided hunk -K - leave this hunk undecided, see previous hunk -s - split the current hunk into smaller hunks -e - manually edit the current hunk -? - print help ----- - -Generally, you'll type `y` or `n` if you want to stage each hunk, but staging all of them in certain files or skipping a hunk decision until later can be helpful too. -If you stage one part of the file and leave another part unstaged, your status output will look like this: - -[source,console] ----- -What now> 1 - staged unstaged path - 1: unchanged +0/-1 TODO - 2: +1/-1 nothing index.html - 3: +1/-1 +4/-0 lib/simplegit.rb ----- +Sam has several options: +* **y (yes):** Stage this hunk. +* **n (no):** Don't stage it. +* **q (quit):** Stop right here and don't stage anything else. +* **s (split):** If the hunk is too big and contains both the "blue color" change and the "spacing" change, `s` will split it into even smaller hunks. +* **? (help):** See a list of all commands. -The status of the `simplegit.rb` file is interesting. -It shows you that a couple of lines are staged and a couple are unstaged. -You've partially staged this file. -At this point, you can exit the interactive adding script and run `git commit` to commit the partially staged files. +==== Sam's Selective Commit +tag::walkthrough[] -You also don't need to be in interactive add mode to do the partial-file staging -- you can start the same script by using `git add -p` or `git add --patch` on the command line. +1. Sam runs `git add -p`. +2. Git shows the `product-brief.md` typo fix. Sam types `y`. +3. Git shows the `design-tokens.json` color change. Sam wants this in a separate commit, so he types `n`. +4. Sam runs `git status` and sees only the brief is staged. +5. He commits: `git commit -m "[Fix: Brief] Correct target audience typo"`. +6. Now he runs `git add .` to stage the rest and commits his UI updates. -Furthermore, you can use patch mode for partially resetting files with the `git reset --patch` command, for checking out parts of files with the `git checkout --patch` command and for stashing parts of files with the `git stash save --patch` command. -We'll go into more details on each of these as we get to more advanced usages of these commands. +By using Patch Mode, Sam keeps his history incredibly clean. Every checkpoint in the SketchSpark repo represents exactly one logical decision, making it much easier for Nora to review his work later. diff --git a/book/07-git-tools/sections/reset.asc b/book/07-git-tools/sections/reset.asc index f5b953417..ab2151731 100644 --- a/book/07-git-tools/sections/reset.asc +++ b/book/07-git-tools/sections/reset.asc @@ -1,331 +1,66 @@ [[_git_reset]] === Reset Demystified +tag::concept[] -Before moving on to more specialized tools, let's talk about the Git `reset` and `checkout` commands. -These commands are two of the most confusing parts of Git when you first encounter them. -They do so many things that it seems hopeless to actually understand them and employ them properly. -For this, we recommend a simple metaphor. +The `reset` and `checkout` commands are often cited as the most confusing parts of Git. To master them, Nora and her team use a simple metaphor: Git manages three different "environments" or "trees" (collections of files). -==== The Three Trees - -An easier way to think about `reset` and `checkout` is through the mental frame of Git being a content manager of three different trees. -By "`tree`" here, we really mean "`collection of files`", not specifically the data structure. -There are a few cases where the index doesn't exactly act like a tree, but for our purposes it is easier to think about it this way for now. - -Git as a system manages and manipulates three trees in its normal operation: +==== The Three Environments +tag::concept[] [cols="1,2",options="header"] |================================ -| Tree | Role -| HEAD | Last commit snapshot, next parent -| Index | Proposed next commit snapshot -| Working Directory | Sandbox +| Environment | Designer's Role +| **HEAD** | **The Last Snapshot:** Your last official design checkpoint on this branch. +| **The Index** | **The Proposed Snapshot:** Your "staging area"—the selection for your next checkpoint. +| **Working Tree** | **The Sandbox:** The actual files you are editing in Figma or VS Code right now. |================================ -===== The HEAD - -HEAD is the pointer to the current branch reference, which is in turn a pointer to the last commit made on that branch. -That means HEAD will be the parent of the next commit that is created. -It's generally simplest to think of HEAD as the snapshot of *your last commit on that branch*. - -In fact, it's pretty easy to see what that snapshot looks like. -Here is an example of getting the actual directory listing and SHA-1 checksums for each file in the HEAD snapshot: - -[source,console] ----- -$ git cat-file -p HEAD -tree cfda3bf379e4f8dba8717dee55aab78aef7f4daf -author Scott Chacon 1301511835 -0700 -committer Scott Chacon 1301511835 -0700 - -initial commit - -$ git ls-tree -r HEAD -100644 blob a906cb2a4a904a152... README -100644 blob 8f94139338f9404f2... Rakefile -040000 tree 99f1a6d12cb4b6f19... lib ----- - -The Git `cat-file` and `ls-tree` commands are "`plumbing`" commands that are used for lower level things and not really used in day-to-day work, but they help us see what's going on here. - -[[_the_index]] -===== The Index - -The _index_ is your *proposed next commit*. -We've also been referring to this concept as Git's "`Staging Area`" as this is what Git looks at when you run `git commit`. - -Git populates this index with a list of all the file contents that were last checked out into your working directory and what they looked like when they were originally checked out. -You then replace some of those files with new versions of them, and `git commit` converts that into the tree for a new commit. - -[source,console] ----- -$ git ls-files -s -100644 a906cb2a4a904a152e80877d4088654daad0c859 0 README -100644 8f94139338f9404f26296befa88755fc2598c289 0 Rakefile -100644 47c6340d6459e05787f644c2447d2595f5d3a54b 0 lib/simplegit.rb ----- +===== 1. HEAD (The Last Snapshot) +HEAD is a pointer to the last commit made on your current branch. It’s the parent of whatever you're about to do next. Think of it as the "stable truth" of your project right now. -Again, here we're using `git ls-files`, which is more of a behind the scenes command that shows you what your index currently looks like. +===== 2. The Index (The Proposed Snapshot) +We’ve been calling this the **Staging Area**. When you run `git add`, you’re telling Git: "Take this version of the file from my Sandbox and put it in my Proposed Snapshot." When you finally run `git commit`, Git just takes whatever is in the Index and makes it the new HEAD. -The index is not technically a tree structure -- it's actually implemented as a flattened manifest -- but for our purposes it's close enough. - -===== The Working Directory - -Finally, you have your _working directory_ (also commonly referred to as the "`working tree`"). -The other two trees store their content in an efficient but inconvenient manner, inside the `.git` folder. -The working directory unpacks them into actual files, which makes it much easier for you to edit them. -Think of the working directory as a *sandbox*, where you can try changes out before committing them to your staging area (index) and then to history. - -[source,console] ----- -$ tree -. -├── README -├── Rakefile -└── lib - └── simplegit.rb - -1 directory, 3 files ----- +===== 3. Working Tree (The Sandbox) +This is where your files actually live on your computer. The other two environments store data efficiently inside the hidden `.git` folder, but the Sandbox is where you do the real work. ==== The Workflow +tag::concept[] -Git's typical workflow is to record snapshots of your project in successively better states, by manipulating these three trees. +Git’s daily rhythm is the movement of data between these three places. -.Git's typical workflow +.The movement of design work through Git image::images/reset-workflow.png[Git's typical workflow] -Let's visualize this process: say you go into a new directory with a single file in it. -We'll call this *v1* of the file, and we'll indicate it in blue. -Now we run `git init`, which will create a Git repository with a HEAD reference which points to the unborn `master` branch. - -.Newly-initialized Git repository with unstaged file in the working directory -image::images/reset-ex1.png[Newly-initialized Git repository with unstaged file in the working directory] - -At this point, only the working directory tree has any content. - -Now we want to commit this file, so we use `git add` to take content in the working directory and copy it to the index. - -.File is copied to index on `git add` -image::images/reset-ex2.png[File is copied to index on `git add`] - -Then we run `git commit`, which takes the contents of the index and saves it as a permanent snapshot, creates a commit object which points to that snapshot, and updates `master` to point to that commit. - -.The `git commit` step -image::images/reset-ex3.png[The `git commit` step] - -If we run `git status`, we'll see no changes, because all three trees are the same. - -Now we want to make a change to that file and commit it. -We'll go through the same process; first, we change the file in our working directory. -Let's call this *v2* of the file, and indicate it in red. - -.Git repository with changed file in the working directory -image::images/reset-ex4.png[Git repository with changed file in the working directory] - -If we run `git status` right now, we'll see the file in red as "`Changes not staged for commit`", because that entry differs between the index and the working directory. -Next we run `git add` on it to stage it into our index. - -.Staging change to index -image::images/reset-ex5.png[Staging change to index] - -At this point, if we run `git status`, we will see the file in green under "`Changes to be committed`" because the index and HEAD differ -- that is, our proposed next commit is now different from our last commit. -Finally, we run `git commit` to finalize the commit. - -.The `git commit` step with changed file -image::images/reset-ex6.png[The `git commit` step with changed file] - -Now `git status` will give us no output, because all three trees are the same again. - -Switching branches or cloning goes through a similar process. -When you checkout a branch, it changes *HEAD* to point to the new branch ref, populates your *index* with the snapshot of that commit, then copies the contents of the *index* into your *working directory*. - -==== The Role of Reset - -The `reset` command makes more sense when viewed in this context. - -For the purposes of these examples, let's say that we've modified `file.txt` again and committed it a third time. -So now our history looks like this: - -.Git repository with three commits -image::images/reset-start.png[Git repository with three commits] - -Let's now walk through exactly what `reset` does when you call it. -It directly manipulates these three trees in a simple and predictable way. -It does up to three basic operations. - -===== Step 1: Move HEAD - -The first thing `reset` will do is move what HEAD points to. -This isn't the same as changing HEAD itself (which is what `checkout` does); `reset` moves the branch that HEAD is pointing to. -This means if HEAD is set to the `master` branch (i.e. you're currently on the `master` branch), running `git reset 9e5e6a4` will start by making `master` point to `9e5e6a4`. - -.Soft reset -image::images/reset-soft.png[Soft reset] - -No matter what form of `reset` with a commit you invoke, this is the first thing it will always try to do. -With `reset --soft`, it will simply stop there. - -Now take a second to look at that diagram and realize what happened: it essentially undid the last `git commit` command. -When you run `git commit`, Git creates a new commit and moves the branch that HEAD points to up to it. -When you `reset` back to `HEAD~` (the parent of HEAD), you are moving the branch back to where it was, without changing the index or working directory. -You could now update the index and run `git commit` again to accomplish what `git commit --amend` would have done (see <<_git_amend>>). - -===== Step 2: Updating the Index (`--mixed`) - -Note that if you run `git status` now you'll see in green the difference between the index and what the new HEAD is. - -The next thing `reset` will do is to update the index with the contents of whatever snapshot HEAD now points to. - -.Mixed reset -image::images/reset-mixed.png[Mixed reset] +1. **Modify:** You edit a file in your **Sandbox**. +2. **Add:** You run `git add`, copying the file to the **Index**. +3. **Commit:** You run `git commit`, taking the state of the **Index** and saving it permanently as the new **HEAD**. -If you specify the `--mixed` option, `reset` will stop at this point. -This is also the default, so if you specify no option at all (just `git reset HEAD~` in this case), this is where the command will stop. +==== The Power of Reset +tag::procedure[] -Now take another second to look at that diagram and realize what happened: it still undid your last `commit`, but also _unstaged_ everything. -You rolled back to before you ran all your `git add` and `git commit` commands. +(((git commands, reset))) +The `reset` command is Nora’s tool for moving data *backward* through these environments. It does three things, stopping where you tell it to: -===== Step 3: Updating the Working Directory (`--hard`) +1. **Move HEAD:** (Reset `--soft`) Move the branch pointer back to an earlier commit. This "undoes" your last commit but leaves your files in the Staging Area. +2. **Update the Index:** (Reset `--mixed`, the default) Also makes the Staging Area match the new HEAD. This "undoes" your staging. +3. **Update the Sandbox:** (Reset `--hard`) Also overwrites your actual files on disk. -The third thing that `reset` will do is to make the working directory look like the index. -If you use the `--hard` option, it will continue to this stage. +[WARNING] +==== +`git reset --hard` is one of the few dangerous commands in Git. It will overwrite your unsaved work in the Sandbox with the version from a previous checkpoint. **Use it only if you are 100% sure you want to discard your current changes.** +==== -.Hard reset -image::images/reset-hard.png[Hard reset] - -So let's think about what just happened. -You undid your last commit, the `git add` and `git commit` commands, *and* all the work you did in your working directory. - -It's important to note that this flag (`--hard`) is the only way to make the `reset` command dangerous, and one of the very few cases where Git will actually destroy data. -Any other invocation of `reset` can be pretty easily undone, but the `--hard` option cannot, since it forcibly overwrites files in the working directory. -In this particular case, we still have the *v3* version of our file in a commit in our Git DB, and we could get it back by looking at our `reflog`, but if we had not committed it, Git still would have overwritten the file and it would be unrecoverable. - -===== Recap - -The `reset` command overwrites these three trees in a specific order, stopping when you tell it to: - -1. Move the branch HEAD points to _(stop here if `--soft`)_. -2. Make the index look like HEAD _(stop here unless `--hard`)_. -3. Make the working directory look like the index. - -==== Reset With a Path - -That covers the behavior of `reset` in its basic form, but you can also provide it with a path to act upon. -If you specify a path, `reset` will skip step 1, and limit the remainder of its actions to a specific file or set of files. -This actually sort of makes sense -- HEAD is just a pointer, and you can't point to part of one commit and part of another. -But the index and working directory _can_ be partially updated, so reset proceeds with steps 2 and 3. - -So, assume we run `git reset file.txt`. -This form (since you did not specify a commit SHA-1 or branch, and you didn't specify `--soft` or `--hard`) is shorthand for `git reset --mixed HEAD file.txt`, which will: - -1. Move the branch HEAD points to _(skipped)_. -2. Make the index look like HEAD _(stop here)_. - -So it essentially just copies `file.txt` from HEAD to the index. - -.Mixed reset with a path -image::images/reset-path1.png[Mixed reset with a path] - -This has the practical effect of _unstaging_ the file. -If we look at the diagram for that command and think about what `git add` does, they are exact opposites. - -.Staging file to index -image::images/reset-path2.png[Staging file to index] - -This is why the output of the `git status` command suggests that you run this to unstage a file (see <<ch02-git-basics-chapter#_unstaging>> for more on this). - -We could just as easily not let Git assume we meant "`pull the data from HEAD`" by specifying a specific commit to pull that file version from. -We would just run something like `git reset eb43bf file.txt`. - -.Soft reset with a path to a specific commit -image::images/reset-path3.png[Soft reset with a path to a specific commit] - -This effectively does the same thing as if we had reverted the content of the file to *v1* in the working directory, ran `git add` on it, then reverted it back to *v3* again (without actually going through all those steps). -If we run `git commit` now, it will record a change that reverts that file back to *v1*, even though we never actually had it in our working directory again. - -It's also interesting to note that like `git add`, the `reset` command will accept a `--patch` option to unstage content on a hunk-by-hunk basis. -So you can selectively unstage or revert content. - -==== Squashing - -Let's look at how to do something interesting with this newfound power -- squashing commits. - -Say you have a series of commits with messages like "`oops.`", "`WIP`" and "`forgot this file`". -You can use `reset` to quickly and easily squash them into a single commit that makes you look really smart. -<<_squashing>> shows another way to do this, but in this example it's simpler to use `reset`. - -Let's say you have a project where the first commit has one file, the second commit added a new file and changed the first, and the third commit changed the first file again. -The second commit was a work in progress and you want to squash it down. - -.Git repository -image::images/reset-squash-r1.png[Git repository] - -You can run `git reset --soft HEAD~2` to move the HEAD branch back to an older commit (the most recent commit you want to keep): - -.Moving HEAD with soft reset -image::images/reset-squash-r2.png[Moving HEAD with soft reset] - -And then simply run `git commit` again: - -.Git repository with squashed commit -image::images/reset-squash-r3.png[Git repository with squashed commit] - -Now you can see that your reachable history, the history you would push, now looks like you had one commit with `file-a.txt` *v1*, then a second that both modified `file-a.txt` to *v3* and added `file-b.txt`. -The commit with the *v2* version of the file is no longer in the history. - -==== Check It Out - -Finally, you may wonder what the difference between `checkout` and `reset` is. -Like `reset`, `checkout` manipulates the three trees, and it is a bit different depending on whether you give the command a file path or not. - -===== Without Paths - -Running `git checkout [branch]` is pretty similar to running `git reset --hard [branch]` in that it updates all three trees for you to look like `[branch]`, but there are two important differences. - -First, unlike `reset --hard`, `checkout` is working-directory safe; it will check to make sure it's not blowing away files that have changes to them. -Actually, it's a bit smarter than that -- it tries to do a trivial merge in the working directory, so all of the files you _haven't_ changed will be updated. -`reset --hard`, on the other hand, will simply replace everything across the board without checking. - -The second important difference is how `checkout` updates HEAD. -Whereas `reset` will move the branch that HEAD points to, `checkout` will move HEAD itself to point to another branch. - -For instance, say we have `master` and `develop` branches which point at different commits, and we're currently on `develop` (so HEAD points to it). -If we run `git reset master`, `develop` itself will now point to the same commit that `master` does. -If we instead run `git checkout master`, `develop` does not move, HEAD itself does. -HEAD will now point to `master`. - -So, in both cases we're moving HEAD to point to commit A, but _how_ we do so is very different. -`reset` will move the branch HEAD points to, `checkout` moves HEAD itself. - -.`git checkout` and `git reset` -image::images/reset-checkout.png[`git checkout` and `git reset`] - -===== With Paths - -The other way to run `checkout` is with a file path, which, like `reset`, does not move HEAD. -It is just like `git reset [branch] file` in that it updates the index with that file at that commit, but it also overwrites the file in the working directory. -It would be exactly like `git reset --hard [branch] file` (if `reset` would let you run that) -- it's not working-directory safe, and it does not move HEAD. - -Also, like `git reset` and `git add`, `checkout` will accept a `--patch` option to allow you to selectively revert file contents on a hunk-by-hunk basis. - -==== Summary - -Hopefully now you understand and feel more comfortable with the `reset` command, but are probably still a little confused about how exactly it differs from `checkout` and could not possibly remember all the rules of the different invocations. - -Here's a cheat-sheet for which commands affect which trees. -The "`HEAD`" column reads "`REF`" if that command moves the reference (branch) that HEAD points to, and "`HEAD`" if it moves HEAD itself. -Pay especial attention to the 'WD Safe?' column -- if it says *NO*, take a second to think before running that command. +==== Summary Cheat-Sheet +tag::reference[] [options="header", cols="3,1,1,1,1"] |================================ -| | HEAD | Index | Workdir | WD Safe? -| *Commit Level* | | | | -| `reset --soft [commit]` | REF | NO | NO | YES -| `reset [commit]` | REF | YES | NO | YES -| `reset --hard [commit]` | REF | YES | YES | *NO* -| `checkout <commit>` | HEAD | YES | YES | YES -| *File Level* | | | | -| `reset [commit] <paths>` | NO | YES | NO | YES -| `checkout [commit] <paths>` | NO | YES | YES | *NO* +| Command | Moves HEAD? | Updates Index? | Updates Sandbox? | Safe for Unsaved Work? +| `reset --soft [commit]` | YES (Branch) | NO | NO | YES +| `reset [commit]` | YES (Branch) | YES | NO | YES +| `reset --hard [commit]` | YES (Branch) | YES | YES | **NO** +| `checkout [branch]` | YES (HEAD) | YES | YES | YES* |================================ + +By understanding the relationship between the Last Snapshot, the Proposed Snapshot, and the Sandbox, Nora and her team can navigate any "undo" scenario with total confidence. diff --git a/book/07-git-tools/sections/revision-selection.asc b/book/07-git-tools/sections/revision-selection.asc index 95e8e8305..eacad6021 100644 --- a/book/07-git-tools/sections/revision-selection.asc +++ b/book/07-git-tools/sections/revision-selection.asc @@ -1,401 +1,86 @@ [[_revision_selection]] === Revision Selection +tag::concept[] -Git allows you to refer to a single commit, set of commits, or range of commits in a number of ways. -They aren't necessarily obvious but are helpful to know. +Git allows you to refer to a single checkpoint, a set of checkpoints, or a range of history in many ways. While you've mostly used branch names so far, there are more precise ways to point to exactly what you need. ==== Single Revisions +tag::concept[] -You can obviously refer to any single commit by its full, 40-character SHA-1 hash, but there are more human-friendly ways to refer to commits as well. -This section outlines the various ways you can refer to any commit. +You can always refer to any checkpoint by its full, 40-character SHA-1 hash (that long string of letters and numbers like `ca82a6d...`). However, there are more human-friendly ways to refer to your work. ==== Short SHA-1 +tag::procedure[] -Git is smart enough to figure out what commit you're referring to if you provide the first few characters of the SHA-1 hash, as long as that partial hash is at least four characters long and unambiguous; that is, no other object in the object database can have a hash that begins with the same prefix. +Git is smart enough to figure out which checkpoint you mean if you provide just the first few characters of the hash, as long as it's at least four characters and unique. -For example, to examine a specific commit where you know you added certain functionality, you might first run the `git log` command to locate the commit: +If Nora wants to see a specific research update she knows is in commit `1c002dd...`, she can just run: -[source,console] +[source,bash] ---- -$ git log -commit 734713bc047d87bf7eac9674765ae793478c50d3 -Author: Scott Chacon <schacon@gmail.com> -Date: Fri Jan 2 18:32:33 2009 -0800 - - Fix refs handling, add gc auto, update tests - -commit d921970aadf03b3cf0e71becdaab3147ba71cdef -Merge: 1c002dd... 35cfb2b... -Author: Scott Chacon <schacon@gmail.com> -Date: Thu Dec 11 15:08:43 2008 -0800 - - Merge commit 'phedders/rdocs' - -commit 1c002dd4b536e7479fe34593e72e6c6c1819e53b -Author: Scott Chacon <schacon@gmail.com> -Date: Thu Dec 11 14:58:32 2008 -0800 - - Add some blame and merge stuff ----- - -In this case, say you're interested in the commit whose hash begins with `1c002dd...`. -You can inspect that commit with any of the following variations of `git show` (assuming the shorter versions are unambiguous): - -[source,console] ----- -$ git show 1c002dd4b536e7479fe34593e72e6c6c1819e53b -$ git show 1c002dd4b536e7479f $ git show 1c002d ---- -Git can figure out a short, unique abbreviation for your SHA-1 values. -If you pass `--abbrev-commit` to the `git log` command, the output will use shorter values but keep them unique; it defaults to using seven characters but makes them longer if necessary to keep the SHA-1 unambiguous: +Git can even help her by abbreviating hashes in the log: -[source,console] +[source,bash] ---- $ git log --abbrev-commit --pretty=oneline -ca82a6d Change the version number -085bb3b Remove unnecessary test code -a11bef0 Initial commit +ca82a6d [Design: Tokens] Update primary blue +085bb3b [Research: Persona] Refine goals ---- -Generally, eight to ten characters are more than enough to be unique within a project. -For example, as of February 2019, the Linux kernel (which is a fairly sizable project) has over 875,000 commits and almost seven million objects in its object database, with no two objects whose SHA-1s are identical in the first 12 characters. - -[NOTE] -.A SHORT NOTE ABOUT SHA-1 -==== - -A lot of people become concerned at some point that they will, by random happenstance, have two distinct objects in their repository that hash to the same SHA-1 value. -What then? - -If you do happen to commit an object that hashes to the same SHA-1 value as a previous _different_ object in your repository, Git will see the previous object already in your Git database, assume it was already written and simply reuse it. -If you try to check out that object again at some point, you'll always get the data of the first object. - -However, you should be aware of how ridiculously unlikely this scenario is. -The SHA-1 digest is 20 bytes or 160 bits. -The number of randomly hashed objects needed to ensure a 50% probability of a single collision is about 2^80^ (the formula for determining collision probability is `p = (n(n-1)/2) * (1/2^160)`). -2^80^ is 1.2 x 10^24^ or 1 million billion billion. -That's 1,200 times the number of grains of sand on the earth. +Generally, 8 to 10 characters are more than enough to be unique. The Linux kernel, with millions of objects, only needs 12 characters to stay unambiguous. -Here's an example to give you an idea of what it would take to get a SHA-1 collision. -If all 6.5 billion humans on Earth were programming, and every second, each one was producing code that was the equivalent of the entire Linux kernel history (6.5 million Git objects) and pushing it into one enormous Git repository, it would take roughly 2 years until that repository contained enough objects to have a 50% probability of a single SHA-1 object collision. -Thus, an organic SHA-1 collision is less likely than every member of your programming team being attacked and killed by wolves in unrelated incidents on the same night. - -If you dedicate several thousands of dollars' worth of computing power to it, it is possible to synthesize two files with the same hash, as proven on https://shattered.io/[^] in February 2017. -Git is moving towards using SHA256 as the default hashing algorithm, which is much more resilient to collision attacks, and has code in place to help mitigate this attack (although it cannot completely eliminate it). -==== - -[[_branch_references]] ==== Branch References +tag::concept[] -One straightforward way to refer to a particular commit is if it's the commit at the tip of a branch; in that case, you can simply use the branch name in any Git command that expects a reference to a commit. -For instance, if you want to examine the last commit object on a branch, the following commands are equivalent, assuming that the `topic1` branch points to commit `ca82a6d...`: +The easiest way to refer to a checkpoint is by the branch it's on. If the `option/card-layout` branch points to `ca82a6d...`, these two commands are identical: -[source,console] +[source,bash] ---- $ git show ca82a6dff817ec66f44342007202690a93763949 -$ git show topic1 +$ git show option/card-layout ---- -If you want to see which specific SHA-1 a branch points to, or if you want to see what any of these examples boils down to in terms of SHA-1s, you can use a Git plumbing tool called `rev-parse`. -You can see <<ch10-git-internals#ch10-git-internals>> for more information about plumbing tools; basically, `rev-parse` exists for lower-level operations and isn't designed to be used in day-to-day operations. -However, it can be helpful sometimes when you need to see what's really going on. -Here you can run `rev-parse` on your branch. +==== RefLog: The Designer's Safety Net +tag::procedure[] -[source,console] ----- -$ git rev-parse topic1 -ca82a6dff817ec66f44342007202690a93763949 ----- +(((reflog))) +While you're working, Git keeps a **RefLog**—a secret log of where your **HEAD** (your current position) has been for the last few months. This is incredibly useful if you accidentally delete a branch or "lose" a commit. -[[_git_reflog]] -==== RefLog Shortnames +Nora can see her recent movements by running: -One of the things Git does in the background while you're working away is keep a "`reflog`" -- a log of where your HEAD and branch references have been for the last few months. - -You can see your reflog by using `git reflog`: - -[source,console] +[source,bash] ---- $ git reflog -734713b HEAD@{0}: commit: Fix refs handling, add gc auto, update tests -d921970 HEAD@{1}: merge phedders/rdocs: Merge made by the 'recursive' strategy. -1c002dd HEAD@{2}: commit: Add some blame and merge stuff -1c36188 HEAD@{3}: rebase -i (squash): updating HEAD -95df984 HEAD@{4}: commit: # This is a combination of two commits. -1c36188 HEAD@{5}: rebase -i (squash): updating HEAD -7e05da5 HEAD@{6}: rebase -i (pick): updating HEAD ----- - -Every time your branch tip is updated for any reason, Git stores that information for you in this temporary history. -You can use your reflog data to refer to older commits as well. -For example, if you want to see the fifth prior value of the HEAD of your repository, you can use the `@{5}` reference that you see in the reflog output: - -[source,console] ----- -$ git show HEAD@{5} ----- - -You can also use this syntax to see where a branch was some specific amount of time ago. -For instance, to see where your `master` branch was yesterday, you can type: - -[source,console] +734713b HEAD@{0}: commit: [Design: Tokens] Update primary blue +d921970 HEAD@{1}: merge option/card-layout: Merge made by recursive. +1c002dd HEAD@{2}: commit: [Research: Setup] Add initial brief ---- -$ git show master@{yesterday} ----- - -That would show you where the tip of your `master` branch was yesterday. -This technique only works for data that's still in your reflog, so you can't use it to look for commits older than a few months. -To see reflog information formatted like the `git log` output, you can run `git log -g`: +Every time Nora switches branches or makes a checkpoint, Git adds an entry here. She can use these `@{n}` references to jump back in time. For example, to see where the project was two "moves" ago: -[source,console] +[source,bash] ---- -$ git log -g master -commit 734713bc047d87bf7eac9674765ae793478c50d3 -Reflog: master@{0} (Scott Chacon <schacon@gmail.com>) -Reflog message: commit: Fix refs handling, add gc auto, update tests -Author: Scott Chacon <schacon@gmail.com> -Date: Fri Jan 2 18:32:33 2009 -0800 - - Fix refs handling, add gc auto, update tests - -commit d921970aadf03b3cf0e71becdaab3147ba71cdef -Reflog: master@{1} (Scott Chacon <schacon@gmail.com>) -Reflog message: merge phedders/rdocs: Merge made by recursive. -Author: Scott Chacon <schacon@gmail.com> -Date: Thu Dec 11 15:08:43 2008 -0800 - - Merge commit 'phedders/rdocs' +$ git show HEAD@{2} ---- -It's important to note that reflog information is strictly local -- it's a log only of what _you've_ done in _your_ repository. -The references won't be the same on someone else's copy of the repository; also, right after you initially clone a repository, you'll have an empty reflog, as no activity has occurred yet in your repository. -Running `git show HEAD@{2.months.ago}` will show you the matching commit only if you cloned the project at least two months ago -- if you cloned it any more recently than that, you'll see only your first local commit. - -[TIP] -.Think of the reflog as Git's version of shell history -==== -If you have a UNIX or Linux background, you can think of the reflog as Git's version of shell history, which emphasizes that what's there is clearly relevant only for you and your "`session`", and has nothing to do with anyone else who might be working on the same machine. -==== - -[NOTE] -.Escaping braces in PowerShell -==== +She can even use time-based references: -When using PowerShell, braces like `{` and `}` are special characters and must be escaped. -You can escape them with a backtick ` or put the commit reference in quotes: - -[source,console] +[source,bash] ---- -$ git show HEAD@{0} # will NOT work -$ git show HEAD@`{0`} # OK -$ git show "HEAD@{0}" # OK +$ git show main@{yesterday} ---- -==== +This shows her exactly where the `main` branch was at this time yesterday. The RefLog is Nora’s ultimate "undo" button for those moments when things go sideways. ==== Ancestry References +tag::concept[] -The other main way to specify a commit is via its ancestry. -If you place a `^` (caret) at the end of a reference, Git resolves it to mean the parent of that commit. -Suppose you look at the history of your project: - -[source,console] ----- -$ git log --pretty=format:'%h %s' --graph -* 734713b Fix refs handling, add gc auto, update tests -* d921970 Merge commit 'phedders/rdocs' -|\ -| * 35cfb2b Some rdoc changes -* | 1c002dd Add some blame and merge stuff -|/ -* 1c36188 Ignore *.gem -* 9b29157 Add open3_detach to gemspec file list ----- - -Then, you can see the previous commit by specifying `HEAD^`, which means "`the parent of HEAD`": - -[source,console] ----- -$ git show HEAD^ -commit d921970aadf03b3cf0e71becdaab3147ba71cdef -Merge: 1c002dd... 35cfb2b... -Author: Scott Chacon <schacon@gmail.com> -Date: Thu Dec 11 15:08:43 2008 -0800 - - Merge commit 'phedders/rdocs' ----- - -[NOTE] -.Escaping the caret on Windows -==== - -On Windows in `cmd.exe`, `^` is a special character and needs to be treated differently. -You can either double it or put the commit reference in quotes: - -[source,console] ----- -$ git show HEAD^ # will NOT work on Windows -$ git show HEAD^^ # OK -$ git show "HEAD^" # OK ----- - -==== - -You can also specify a number after the `^` to identify _which_ parent you want; for example, `d921970^2` means "`the second parent of d921970.`" -This syntax is useful only for merge commits, which have more than one parent -- the _first_ parent of a merge commit is from the branch you were on when you merged (frequently `master`), while the _second_ parent of a merge commit is from the branch that was merged (say, `topic`): - -[source,console] ----- -$ git show d921970^ -commit 1c002dd4b536e7479fe34593e72e6c6c1819e53b -Author: Scott Chacon <schacon@gmail.com> -Date: Thu Dec 11 14:58:32 2008 -0800 - - Add some blame and merge stuff +Sometimes you want to refer to a checkpoint relative to another one (e.g., "the one before this one"). -$ git show d921970^2 -commit 35cfb2b795a55793d7cc56a6cc2060b4bb732548 -Author: Paul Hedderly <paul+git@mjr.org> -Date: Wed Dec 10 22:22:03 2008 +0000 - - Some rdoc changes ----- - -The other main ancestry specification is the `~` (tilde). -This also refers to the first parent, so `HEAD~` and `HEAD^` are equivalent. -The difference becomes apparent when you specify a number. -`HEAD~2` means "`the first parent of the first parent,`" or "`the grandparent`" -- it traverses the first parents the number of times you specify. -For example, in the history listed earlier, `HEAD~3` would be: - -[source,console] ----- -$ git show HEAD~3 -commit 1c3618887afb5fbcbea25b7c013f4e2114448b8d -Author: Tom Preston-Werner <tom@mojombo.com> -Date: Fri Nov 7 13:47:59 2008 -0500 - - Ignore *.gem ----- - -This can also be written `HEAD\~~~`, which again is the first parent of the first parent of the first parent: - -[source,console] ----- -$ git show HEAD~~~ -commit 1c3618887afb5fbcbea25b7c013f4e2114448b8d -Author: Tom Preston-Werner <tom@mojombo.com> -Date: Fri Nov 7 13:47:59 2008 -0500 - - Ignore *.gem ----- - -You can also combine these syntaxes -- you can get the second parent of the previous reference (assuming it was a merge commit) by using `HEAD~3^2`, and so on. - -[[_commit_ranges]] -==== Commit Ranges - -Now that you can specify individual commits, let's see how to specify ranges of commits. -This is particularly useful for managing your branches -- if you have a lot of branches, you can use range specifications to answer questions such as, "`What work is on this branch that I haven't yet merged into my main branch?`" - -===== Double Dot - -The most common range specification is the double-dot syntax. -This basically asks Git to resolve a range of commits that are reachable from one commit but aren't reachable from another. -For example, say you have a commit history that looks like <<double_dot>>. - -[[double_dot]] -.Example history for range selection -image::images/double-dot.png[Example history for range selection] - -Say you want to see what is in your `experiment` branch that hasn't yet been merged into your `master` branch. -You can ask Git to show you a log of just those commits with `master..experiment` -- that means "`all commits reachable from `experiment` that aren't reachable from `master`.`" -For the sake of brevity and clarity in these examples, the letters of the commit objects from the diagram are used in place of the actual log output in the order that they would display: - -[source,console] ----- -$ git log master..experiment -D -C ----- - -If, on the other hand, you want to see the opposite -- all commits in `master` that aren't in `experiment` -- you can reverse the branch names. -`experiment..master` shows you everything in `master` not reachable from `experiment`: - -[source,console] ----- -$ git log experiment..master -F -E ----- - -This is useful if you want to keep the `experiment` branch up to date and preview what you're about to merge. -Another frequent use of this syntax is to see what you're about to push to a remote: - -[source,console] ----- -$ git log origin/master..HEAD ----- - -This command shows you any commits in your current branch that aren't in the `master` branch on your `origin` remote. -If you run a `git push` and your current branch is tracking `origin/master`, the commits listed by `git log origin/master..HEAD` are the commits that will be transferred to the server. -You can also leave off one side of the syntax to have Git assume `HEAD`. -For example, you can get the same results as in the previous example by typing `git log origin/master..` -- Git substitutes `HEAD` if one side is missing. - -===== Multiple Points - -The double-dot syntax is useful as a shorthand, but perhaps you want to specify more than two branches to indicate your revision, such as seeing what commits are in any of several branches that aren't in the branch you're currently on. -Git allows you to do this by using either the `^` character or `--not` before any reference from which you don't want to see reachable commits. -Thus, the following three commands are equivalent: - -[source,console] ----- -$ git log refA..refB -$ git log ^refA refB -$ git log refB --not refA ----- - -This is nice because with this syntax you can specify more than two references in your query, which you cannot do with the double-dot syntax. -For instance, if you want to see all commits that are reachable from `refA` or `refB` but not from `refC`, you can use either of: - -[source,console] ----- -$ git log refA refB ^refC -$ git log refA refB --not refC ----- - -This makes for a very powerful revision query system that should help you figure out what is in your branches. - -[[_triple_dot]] -===== Triple Dot - -The last major range-selection syntax is the triple-dot syntax, which specifies all the commits that are reachable by _either_ of two references but not by both of them. -Look back at the example commit history in <<double_dot>>. -If you want to see what is in `master` or `experiment` but not any common references, you can run: - -[source,console] ----- -$ git log master...experiment -F -E -D -C ----- - -Again, this gives you normal `log` output but shows you only the commit information for those four commits, appearing in the traditional commit date ordering. - -A common switch to use with the `log` command in this case is `--left-right`, which shows you which side of the range each commit is in. -This helps make the output more useful: - -[source,console] ----- -$ git log --left-right master...experiment -< F -< E -> D -> C ----- +* **The Tilde (`~`):** `HEAD~` means the parent of the current checkpoint. `HEAD~2` means the grandparent (two steps back). +* **The Caret (`^`):** This is similar, but it matters during merges. `HEAD^` is the first parent (the branch you were on), while `HEAD^2` is the second parent (the branch you merged in). -With these tools, you can much more easily let Git know what commit or commits you want to inspect. +For Nora, `HEAD~3` is a quick way to say "show me the three most recent design decisions on this branch." diff --git a/book/07-git-tools/sections/rewriting-history.asc b/book/07-git-tools/sections/rewriting-history.asc index 7fbb06d7f..e84573396 100644 --- a/book/07-git-tools/sections/rewriting-history.asc +++ b/book/07-git-tools/sections/rewriting-history.asc @@ -1,402 +1,76 @@ [[_rewriting_history]] === Rewriting History +tag::concept[] -Many times, when working with Git, you may want to revise your local commit history. -One of the great things about Git is that it allows you to make decisions at the last possible moment. -You can decide what files go into which commits right before you commit with the staging area, you can decide that you didn't mean to be working on something yet with `git stash`, and you can rewrite commits that already happened so they look like they happened in a different way. -This can involve changing the order of the commits, changing messages or modifying files in a commit, squashing together or splitting apart commits, or removing commits entirely -- all before you share your work with others. +Many times, when you're working locally, you'll make "oops" commits or multiple small checkpoints that don't quite make sense on their own. Just as a designer wouldn't show every messy rough sketch to a client, you might want to curate your Git history before sharing it with the team. -In this section, you'll see how to accomplish these tasks so that you can make your commit history look the way you want before you share it with others. +In this section, we’ll follow Nora as she uses Git’s "editing desk" to clean up her team’s work. -[NOTE] -.Don't push your work until you're happy with it -==== -One of the cardinal rules of Git is that, since so much work is local within your clone, you have a great deal of freedom to rewrite your history _locally_. -However, once you push your work, it is a different story entirely, and you should consider pushed work as final unless you have good reason to change it. -In short, you should avoid pushing your work until you're happy with it and ready to share it with the rest of the world. -==== - -[[_git_amend]] -==== Changing the Last Commit - -Changing your most recent commit is probably the most common rewriting of history that you'll do. -You'll often want to do two basic things to your last commit: simply change the commit message, or change the actual content of the commit by adding, removing and modifying files. - -If you simply want to modify your last commit message, that's easy: - -[source,console] ----- -$ git commit --amend ----- - -The command above loads the previous commit message into an editor session, where you can make changes to the message, save those changes and exit. -When you save and close the editor, the editor writes a new commit containing that updated commit message and makes it your new last commit. - -If, on the other hand, you want to change the actual _content_ of your last commit, the process works basically the same way -- first make the changes you think you forgot, stage those changes, and the subsequent `git commit --amend` _replaces_ that last commit with your new, improved commit. - -You need to be careful with this technique because amending changes the SHA-1 of the commit. -It's like a very small rebase -- don't amend your last commit if you've already pushed it. - -[TIP] -.An amended commit may (or may not) need an amended commit message -==== -When you amend a commit, you have the opportunity to change both the commit message and the content of the commit. -If you amend the content of the commit substantially, you should almost certainly update the commit message to reflect that amended content. - -On the other hand, if your amendments are suitably trivial (fixing a silly typo or adding a file you forgot to stage) such that the earlier commit message is just fine, you can simply make the changes, stage them, and avoid the unnecessary editor session entirely with: - -[source,console] ----- -$ git commit --amend --no-edit ----- - -==== - -[[_changing_multiple]] -==== Changing Multiple Commit Messages - -To modify a commit that is farther back in your history, you must move to more complex tools. -Git doesn't have a modify-history tool, but you can use the rebase tool to rebase a series of commits onto the HEAD that they were originally based on instead of moving them to another one. -With the interactive rebase tool, you can then stop after each commit you want to modify and change the message, add files, or do whatever you wish. -You can run rebase interactively by adding the `-i` option to `git rebase`. -You must indicate how far back you want to rewrite commits by telling the command which commit to rebase onto. - -For example, if you want to change the last three commit messages, or any of the commit messages in that group, you supply as an argument to `git rebase -i` the parent of the last commit you want to edit, which is `HEAD~2^` or `HEAD~3`. -It may be easier to remember the `~3` because you're trying to edit the last three commits, but keep in mind that you're actually designating four commits ago, the parent of the last commit you want to edit: - -[source,console] ----- -$ git rebase -i HEAD~3 ----- - -Remember again that this is a rebasing command -- every commit in the range `HEAD~3..HEAD` with a changed message _and all of its descendants_ will be rewritten. -Don't include any commit you've already pushed to a central server -- doing so will confuse other developers by providing an alternate version of the same change. +==== Changing the Most Recent Commit +tag::procedure[] -Running this command gives you a list of commits in your text editor that looks something like this: +We already covered `git commit --amend` in Chapter 2. It’s Nora’s quickest way to fix a typo or add a forgotten file to her very last checkpoint. -[source,console] ----- -pick f7f3f6d Change my name a bit -pick 310154e Update README formatting and add blame -pick a5f4a0d Add cat-file - -# Rebase 710f0f8..a5f4a0d onto 710f0f8 -# -# Commands: -# p, pick <commit> = use commit -# r, reword <commit> = use commit, but edit the commit message -# e, edit <commit> = use commit, but stop for amending -# s, squash <commit> = use commit, but meld into previous commit -# f, fixup <commit> = like "squash", but discard this commit's log message -# x, exec <command> = run command (the rest of the line) using shell -# b, break = stop here (continue rebase later with 'git rebase --continue') -# d, drop <commit> = remove commit -# l, label <label> = label current HEAD with a name -# t, reset <label> = reset HEAD to a label -# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>] -# . create a merge commit using the original merge commit's -# . message (or the oneline, if no original merge commit was -# . specified). Use -c <commit> to reword the commit message. -# -# These lines can be re-ordered; they are executed from top to bottom. -# -# If you remove a line here THAT COMMIT WILL BE LOST. -# -# However, if you remove everything, the rebase will be aborted. -# -# Note that empty commits are commented out ----- - -It's important to note that these commits are listed in the opposite order than you normally see them using the `log` command. -If you run a `log`, you see something like this: - -[source,console] ----- -$ git log --pretty=format:"%h %s" HEAD~3..HEAD -a5f4a0d Add cat-file -310154e Update README formatting and add blame -f7f3f6d Change my name a bit ----- +==== Changing Multiple Commits +tag::procedure[] -Notice the reverse order. -The interactive rebase gives you a script that it's going to run. -It will start at the commit you specify on the command line (`HEAD~3`) and replay the changes introduced in each of these commits from top to bottom. -It lists the oldest at the top, rather than the newest, because that's the first one it will replay. +(((git commands, rebase, interactive))) +What if Nora wants to fix something further back in time? For this, she uses **Interactive Rebase**. -You need to edit the script so that it stops at the commit you want to edit. -To do so, change the word "`pick`" to the word "`edit`" for each of the commits you want the script to stop after. -For example, to modify only the third commit message, you change the file to look like this: +Suppose Nora has three commits on her `feature/onboarding` branch: +1. `310154e` [Onboarding] Add initial wireframes +2. `f7f3f6d` Oops, forgot the logo +3. `a5f4a0d` WIP: fixing padding -[source,console] ----- -edit f7f3f6d Change my name a bit -pick 310154e Update README formatting and add blame -pick a5f4a0d Add cat-file ----- +She wants to combine these into a single, professional commit: `[Design: Onboarding] Implement initial layout and branding`. -When you save and exit the editor, Git rewinds you back to the last commit in that list and drops you on the command line with the following message: +She runs: -[source,console] +[source,bash] ---- $ git rebase -i HEAD~3 -Stopped at f7f3f6d... Change my name a bit -You can amend the commit now, with - - git commit --amend - -Once you're satisfied with your changes, run - - git rebase --continue ---- -These instructions tell you exactly what to do. -Type: +This opens her editor with a "script" of what Git is about to do: -[source,console] +[source,text] ---- -$ git commit --amend +pick 310154e [Onboarding] Add initial wireframes +pick f7f3f6d Oops, forgot the logo +pick a5f4a0d WIP: fixing padding ---- -Change the commit message, and exit the editor. -Then, run: +==== The Nora "Clean Up" Workflow +tag::walkthrough[] -[source,console] ----- -$ git rebase --continue ----- +Nora can change the word `pick` to various commands: +* **reword:** Keep the change but edit the message. +* **edit:** Stop and let her change the files. +* **squash:** Combine this commit with the one above it. +* **drop:** Delete this commit entirely. -This command will apply the other two commits automatically, and then you're done. -If you change `pick` to `edit` on more lines, you can repeat these steps for each commit you change to `edit`. -Each time, Git will stop, let you amend the commit, and continue when you're finished. +She changes her script to: -==== Reordering Commits - -You can also use interactive rebases to reorder or remove commits entirely. -If you want to remove the "`Add cat-file`" commit and change the order in which the other two commits are introduced, you can change the rebase script from this: - -[source,console] +[source,text] ---- -pick f7f3f6d Change my name a bit -pick 310154e Update README formatting and add blame -pick a5f4a0d Add cat-file +pick 310154e [Onboarding] Add initial wireframes +squash f7f3f6d Oops, forgot the logo +squash a5f4a0d WIP: fixing padding ---- -to this: - -[source,console] ----- -pick 310154e Update README formatting and add blame -pick f7f3f6d Change my name a bit ----- - -When you save and exit the editor, Git rewinds your branch to the parent of these commits, applies `310154e` and then `f7f3f6d`, and then stops. -You effectively change the order of those commits and remove the "`Add cat-file`" commit completely. - -[[_squashing]] -==== Squashing Commits +When she saves and exits, Git combines the three snapshots and asks her to write a new, unified message. She writes `[Design: Onboarding] Implement initial layout and branding`. -It's also possible to take a series of commits and squash them down into a single commit with the interactive rebasing tool. -The script puts helpful instructions in the rebase message: +Now, when Sam pulls the latest changes, he sees a clean, logical progression instead of Nora's "messy work." -[source,console] ----- -# -# Commands: -# p, pick <commit> = use commit -# r, reword <commit> = use commit, but edit the commit message -# e, edit <commit> = use commit, but stop for amending -# s, squash <commit> = use commit, but meld into previous commit -# f, fixup <commit> = like "squash", but discard this commit's log message -# x, exec <command> = run command (the rest of the line) using shell -# b, break = stop here (continue rebase later with 'git rebase --continue') -# d, drop <commit> = remove commit -# l, label <label> = label current HEAD with a name -# t, reset <label> = reset HEAD to a label -# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>] -# . create a merge commit using the original merge commit's -# . message (or the oneline, if no original merge commit was -# . specified). Use -c <commit> to reword the commit message. -# -# These lines can be re-ordered; they are executed from top to bottom. -# -# If you remove a line here THAT COMMIT WILL BE LOST. -# -# However, if you remove everything, the rebase will be aborted. -# -# Note that empty commits are commented out ----- - -If, instead of "`pick`" or "`edit`", you specify "`squash`", Git applies both that change and the change directly before it and makes you merge the commit messages together. -So, if you want to make a single commit from these three commits, you make the script look like this: - -[source,console] ----- -pick f7f3f6d Change my name a bit -squash 310154e Update README formatting and add blame -squash a5f4a0d Add cat-file ----- - -When you save and exit the editor, Git applies all three changes and then puts you back into the editor to merge the three commit messages: - -[source,console] ----- -# This is a combination of 3 commits. -# The first commit's message is: -Change my name a bit - -# This is the 2nd commit message: - -Update README formatting and add blame - -# This is the 3rd commit message: - -Add cat-file ----- - -When you save that, you have a single commit that introduces the changes of all three previous commits. - -==== Splitting a Commit - -Splitting a commit undoes a commit and then partially stages and commits as many times as commits you want to end up with. -For example, suppose you want to split the middle commit of your three commits. -Instead of "`Update README formatting and add blame`", you want to split it into two commits: "`Update README formatting`" for the first, and "`Add blame`" for the second. -You can do that in the `rebase -i` script by changing the instruction on the commit you want to split to "`edit`": - -[source,console] ----- -pick f7f3f6d Change my name a bit -edit 310154e Update README formatting and add blame -pick a5f4a0d Add cat-file ----- - -Then, when the script drops you to the command line, you reset that commit, take the changes that have been reset, and create multiple commits out of them. -When you save and exit the editor, Git rewinds to the parent of the first commit in your list, applies the first commit (`f7f3f6d`), applies the second (`310154e`), and drops you to the console. -There, you can do a mixed reset of that commit with `git reset HEAD^`, which effectively undoes that commit and leaves the modified files unstaged. -Now you can stage and commit files until you have several commits, and run `git rebase --continue` when you're done: - -[source,console] ----- -$ git reset HEAD^ -$ git add README -$ git commit -m 'Update README formatting' -$ git add lib/simplegit.rb -$ git commit -m 'Add blame' -$ git rebase --continue ----- - -Git applies the last commit (`a5f4a0d`) in the script, and your history looks like this: - -[source,console] ----- -$ git log -4 --pretty=format:"%h %s" -1c002dd Add cat-file -9b29157 Add blame -35cfb2b Update README formatting -f7f3f6d Change my name a bit ----- - -This changes the SHA-1s of the three most recent commits in your list, so make sure no changed commit shows up in that list that you've already pushed to a shared repository. -Notice that the last commit (`f7f3f6d`) in the list is unchanged. -Despite this commit being shown in the script, because it was marked as "`pick`" and was applied prior to any rebase changes, Git leaves the commit unmodified. - -==== Deleting a commit - -If you want to get rid of a commit, you can delete it using the `rebase -i` script. -In the list of commits, put the word "`drop`" before the commit you want to delete (or just delete that line from the rebase script): - -[source,console] ----- -pick 461cb2a This commit is OK -drop 5aecc10 This commit is broken ----- - -Because of the way Git builds commit objects, deleting or altering a commit will cause the rewriting of all the commits that follow it. -The further back in your repo's history you go, the more commits will need to be recreated. -This can cause lots of merge conflicts if you have many commits later in the sequence that depend on the one you just deleted. - -If you get partway through a rebase like this and decide it's not a good idea, you can always stop. -Type `git rebase --abort`, and your repo will be returned to the state it was in before you started the rebase. - -If you finish a rebase and decide it's not what you want, you can use `git reflog` to recover an earlier version of your branch. -See <<ch10-git-internals#_data_recovery>> for more information on the `reflog` command. - -[NOTE] +[WARNING] ==== -Drew DeVault made a practical hands-on guide with exercises to learn how to use `git rebase`. -You can find it at: https://git-rebase.io/[^] +Never rewrite history that you have already pushed to a shared server. If Nora rewrites her `feature` branch after Sam has already pulled it, Sam’s repository will become confused and full of duplicate work. **Rewriting is for local, un-pushed work only.** ==== ==== The Nuclear Option: filter-branch +tag::warning[] -There is another history-rewriting option that you can use if you need to rewrite a larger number of commits in some scriptable way -- for instance, changing your email address globally or removing a file from every commit. -The command is `filter-branch`, and it can rewrite huge swaths of your history, so you probably shouldn't use it unless your project isn't yet public and other people haven't based work off the commits you're about to rewrite. -However, it can be very useful. -You'll learn a few of the common uses so you can get an idea of some of the things it's capable of. - -[CAUTION] -==== -`git filter-branch` has many pitfalls, and is no longer the recommended way to rewrite history. -Instead, consider using `git-filter-repo`, which is a Python script that does a better job for most applications where you would normally turn to `filter-branch`. -Its documentation and source code can be found at https://github.com/newren/git-filter-repo[^]. -==== - -[[_removing_file_every_commit]] -===== Removing a File from Every Commit - -This occurs fairly commonly. -Someone accidentally commits a huge binary file with a thoughtless `git add .`, and you want to remove it everywhere. -Perhaps you accidentally committed a file that contained a password, and you want to make your project open source. -`filter-branch` is the tool you probably want to use to scrub your entire history. -To remove a file named `passwords.txt` from your entire history, you can use the `--tree-filter` option to `filter-branch`: - -[source,console] ----- -$ git filter-branch --tree-filter 'rm -f passwords.txt' HEAD -Rewrite 6b9b3cf04e7c5686a9cb838c3f36a8cb6a0fc2bd (21/21) -Ref 'refs/heads/master' was rewritten ----- - -The `--tree-filter` option runs the specified command after each checkout of the project and then recommits the results. -In this case, you remove a file called `passwords.txt` from every snapshot, whether it exists or not. -If you want to remove all accidentally committed editor backup files, you can run something like `git filter-branch --tree-filter 'rm -f *~' HEAD`. - -You'll be able to watch Git rewriting trees and commits and then move the branch pointer at the end. -It's generally a good idea to do this in a testing branch and then hard-reset your `master` branch after you've determined the outcome is what you really want. -To run `filter-branch` on all your branches, you can pass `--all` to the command. - -===== Making a Subdirectory the New Root - -Suppose you've done an import from another source control system and have subdirectories that make no sense (`trunk`, `tags`, and so on). -If you want to make the `trunk` subdirectory be the new project root for every commit, `filter-branch` can help you do that, too: - -[source,console] ----- -$ git filter-branch --subdirectory-filter trunk HEAD -Rewrite 856f0bf61e41a27326cdae8f09fe708d679f596f (12/12) -Ref 'refs/heads/master' was rewritten ----- - -Now your new project root is what was in the `trunk` subdirectory each time. -Git will also automatically remove commits that did not affect the subdirectory. - -===== Changing Email Addresses Globally - -Another common case is that you forgot to run `git config` to set your name and email address before you started working, or perhaps you want to open-source a project at work and change all your work email addresses to your personal address. -In any case, you can change email addresses in multiple commits in a batch with `filter-branch` as well. -You need to be careful to change only the email addresses that are yours, so you use `--commit-filter`: - -[source,console] ----- -$ git filter-branch --commit-filter ' - if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ]; - then - GIT_AUTHOR_NAME="Scott Chacon"; - GIT_AUTHOR_EMAIL="schacon@example.com"; - git commit-tree "$@"; - else - git commit-tree "$@"; - fi' HEAD ----- +(((git commands, filter-branch))) +If Nora accidentally commits a file containing a sensitive API key or a massive 1GB video file into her history, `rebase -i` might be too tedious. For "scrubbing" an entire repo, there is `git filter-branch` (or the newer `git-filter-repo`). -This goes through and rewrites every commit to have your new address. -Because commits contain the SHA-1 values of their parents, this command changes every commit SHA-1 in your history, not just those that have the matching email address. +These tools can reach into every single commit in the project's past and remove a specific file or change an email address globally. They are powerful but dangerous, as they rewrite *every* SHA-1 in the repository. Only use them as a last resort. diff --git a/book/07-git-tools/sections/searching.asc b/book/07-git-tools/sections/searching.asc index 8caf1230f..220c1a3d3 100644 --- a/book/07-git-tools/sections/searching.asc +++ b/book/07-git-tools/sections/searching.asc @@ -1,160 +1,51 @@ [[_searching]] === Searching +tag::concept[] -With just about any size codebase, you'll often need to find where a function is called or defined, or display the history of a method. -Git provides a couple of useful tools for looking through the code and commits stored in its database quickly and easily. -We'll go through a few of them. +As the SketchSpark project grows to hundreds of files and thousands of commits, Nora and her team need a way to find specific information quickly. Git provides several built-in tools for searching through your history and your files. -[[_git_grep]] ==== Git Grep +tag::procedure[] -Git ships with a command called `grep` that allows you to easily search through any committed tree, the working directory, or even the index for a string or regular expression. -For the examples that follow, we'll search through the source code for Git itself. +(((git commands, grep))) +Suppose Nora needs to find every file that references the "early-adopter" persona. Instead of using her computer's built-in search (which might be slow or include deleted files), she uses `git grep`. -By default, `git grep` will look through the files in your working directory. -As a first variation, you can use either of the `-n` or `--line-number` options to print out the line numbers where Git has found matches: - -[source,console] +[source,bash] ---- -$ git grep -n gmtime_r -compat/gmtime.c:3:#undef gmtime_r -compat/gmtime.c:8: return git_gmtime_r(timep, &result); -compat/gmtime.c:11:struct tm *git_gmtime_r(const time_t *timep, struct tm *result) -compat/gmtime.c:16: ret = gmtime_r(timep, result); -compat/mingw.c:826:struct tm *gmtime_r(const time_t *timep, struct tm *result) -compat/mingw.h:206:struct tm *gmtime_r(const time_t *timep, struct tm *result); -date.c:482: if (gmtime_r(&now, &now_tm)) -date.c:545: if (gmtime_r(&time, tm)) { -date.c:758: /* gmtime_r() in match_digit() may have clobbered it */ -git-compat-util.h:1138:struct tm *git_gmtime_r(const time_t *, struct tm *); -git-compat-util.h:1140:#define gmtime_r git_gmtime_r +$ git grep "early-adopter" +research/personas/early-adopter.md:## Early Adopter Profile +research/interview-notes/2026-03-12.md:Mentioned the "early-adopter" goals... ---- -In addition to the basic search shown above, `git grep` supports a plethora of other interesting options. - -For instance, instead of printing all of the matches, you can ask `git grep` to summarize the output by showing you only which files contained the search string and how many matches there were in each file with the `-c` or `--count` option: +`git grep` is incredibly fast because it only searches the files in your Git repository. It can also search older versions of your project. If Nora wants to see where that term was used in an old tag: -[source,console] +[source,bash] ---- -$ git grep --count gmtime_r -compat/gmtime.c:4 -compat/mingw.c:1 -compat/mingw.h:1 -date.c:3 -git-compat-util.h:2 +$ git grep "early-adopter" v0.1-concept ---- -If you're interested in the _context_ of a search string, you can display the enclosing method or function for each matching string with either of the `-p` or `--show-function` options: +==== Tracing the Evolution of a Line +tag::procedure[] -[source,console] ----- -$ git grep -p gmtime_r *.c -date.c=static int match_multi_number(timestamp_t num, char c, const char *date, -date.c: if (gmtime_r(&now, &now_tm)) -date.c=static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt) -date.c: if (gmtime_r(&time, tm)) { -date.c=int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset) -date.c: /* gmtime_r() in match_digit() may have clobbered it */ ----- +One of the most powerful tools for a designer is the **Line Log**. Suppose Sam wants to see how a specific design token—like the `primary-blue` color—has changed over time. -As you can see, the `gmtime_r` routine is called from both the `match_multi_number` and `match_digit` functions in the `date.c` file (the third match displayed represents just the string appearing in a comment). +He can tell Git to show him every commit that touched a specific range of lines in a file. If the color token is on line 5 of `design-tokens.json`: -You can also search for complex combinations of strings with the `--and` flag, which ensures that multiple matches must occur in the same line of text. -For instance, let's look for any lines that define a constant whose name contains _either_ of the substrings "`LINK`" or "`BUF_MAX`", specifically in an older version of the Git codebase represented by the tag `v1.8.0` (we'll throw in the `--break` and `--heading` options which help split up the output into a more readable format): - -[source,console] +[source,bash] ---- -$ git grep --break --heading \ - -n -e '#define' --and \( -e LINK -e BUF_MAX \) v1.8.0 -v1.8.0:builtin/index-pack.c -62:#define FLAG_LINK (1u<<20) - -v1.8.0:cache.h -73:#define S_IFGITLINK 0160000 -74:#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK) - -v1.8.0:environment.c -54:#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS - -v1.8.0:strbuf.c -326:#define STRBUF_MAXLINK (2*PATH_MAX) - -v1.8.0:symlinks.c -53:#define FL_SYMLINK (1 << 2) - -v1.8.0:zlib.c -30:/* #define ZLIB_BUF_MAX ((uInt)-1) */ -31:#define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */ +$ git log -L 5,5:design-tokens.json ---- -The `git grep` command has a few advantages over normal searching commands like `grep` and `ack`. -The first is that it's really fast, the second is that you can search through any tree in Git, not just the working directory. -As we saw in the above example, we looked for terms in an older version of the Git source code, not the version that was currently checked out. +Git will show Sam a "micro-history" of just that one line. He can see every time the color was tweaked, who changed it, and why. This is a game-changer for auditing design systems and understanding how a project's visual language has evolved. -==== Git Log Searching +==== Searching Commit Messages +tag::procedure[] -Perhaps you're looking not for _where_ a term exists, but _when_ it existed or was introduced. -The `git log` command has a number of powerful tools for finding specific commits by the content of their messages or even the content of the diff they introduce. +Nora can also search through her team's "ledger of decisions" using the `--grep` flag with `git log`. To see all commits related to "Contrast": -If, for example, we want to find out when the `ZLIB_BUF_MAX` constant was originally introduced, we can use the `-S` option (colloquially referred to as the Git "`pickaxe`" option) to tell Git to show us only those commits that changed the number of occurrences of that string. - -[source,console] ----- -$ git log -S ZLIB_BUF_MAX --oneline -e01503b zlib: allow feeding more than 4GB in one go -ef49a7a zlib: zlib can only process 4GB at a time +[source,bash] ---- - -If we look at the diff of those commits, we can see that in `ef49a7a` the constant was introduced and in `e01503b` it was modified. - -If you need to be more specific, you can provide a regular expression to search for with the `-G` option. - -===== Line Log Search - -Another fairly advanced log search that is insanely useful is the line history search. -Simply run `git log` with the `-L` option, and it will show you the history of a function or line of code in your codebase. - -For example, if we wanted to see every change made to the function `git_deflate_bound` in the `zlib.c` file, we could run `git log -L :git_deflate_bound:zlib.c`. -This will try to figure out what the bounds of that function are and then look through the history and show us every change that was made to the function as a series of patches back to when the function was first created. - -[source,console] ----- -$ git log -L :git_deflate_bound:zlib.c -commit ef49a7a0126d64359c974b4b3b71d7ad42ee3bca -Author: Junio C Hamano <gitster@pobox.com> -Date: Fri Jun 10 11:52:15 2011 -0700 - - zlib: zlib can only process 4GB at a time - -diff --git a/zlib.c b/zlib.c ---- a/zlib.c -+++ b/zlib.c -@@ -85,5 +130,5 @@ --unsigned long git_deflate_bound(z_streamp strm, unsigned long size) -+unsigned long git_deflate_bound(git_zstream *strm, unsigned long size) - { -- return deflateBound(strm, size); -+ return deflateBound(&strm->z, size); - } - - -commit 225a6f1068f71723a910e8565db4e252b3ca21fa -Author: Junio C Hamano <gitster@pobox.com> -Date: Fri Jun 10 11:18:17 2011 -0700 - - zlib: wrap deflateBound() too - -diff --git a/zlib.c b/zlib.c ---- a/zlib.c -+++ b/zlib.c -@@ -81,0 +85,5 @@ -+unsigned long git_deflate_bound(z_streamp strm, unsigned long size) -+{ -+ return deflateBound(strm, size); -+} -+ +$ git log --grep="Contrast" ---- -If Git can't figure out how to match a function or method in your programming language, you can also provide it with a regular expression (or _regex_). -For example, this would have done the same thing as the example above: `git log -L '/unsigned long git_deflate_bound/',/^}/:zlib.c`. -You could also give it a range of lines or a single line number and you'll get the same sort of output. +By using these search tools, Nora and Sam can treat their repository as a **living archive**, making it easy to find any decision or asset in seconds. diff --git a/book/07-git-tools/sections/stashing-cleaning.asc b/book/07-git-tools/sections/stashing-cleaning.asc index 7337895c7..14cb7f81a 100644 --- a/book/07-git-tools/sections/stashing-cleaning.asc +++ b/book/07-git-tools/sections/stashing-cleaning.asc @@ -1,294 +1,69 @@ [[_git_stashing]] === Stashing and Cleaning +tag::concept[] -Often, when you've been working on part of your project, things are in a messy state and you want to switch branches for a bit to work on something else. -The problem is, you don't want to do a commit of half-done work just so you can get back to this point later. -The answer to this issue is the `git stash` command. +Suppose Priya, the team's illustrator, is halfway through a complex set of onboarding illustrations. Her workspace is a mess: she has three new PNGs, two modified SVG files, and a bunch of temporary export junk. -Stashing takes the dirty state of your working directory -- that is, your modified tracked files and staged changes -- and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch). +Suddenly, Nora calls. There's a critical contrast issue on the landing page that needs an immediate fix on the `main` branch. -[NOTE] -.Migrating to `git stash push` -==== -As of late October 2017, there has been extensive discussion on the Git mailing list, wherein the command `git stash save` is being deprecated in favour of the existing alternative `git stash push`. -The main reason for this is that `git stash push` introduces the option of stashing selected _pathspecs_, something `git stash save` does not support. - -`git stash save` is not going away any time soon, so don't worry about it suddenly disappearing. -But you might want to start migrating over to the `push` alternative for the new functionality. -==== +Priya doesn't want to commit her "work-in-progress" illustrations because they're not ready for the team to see. She also doesn't want to lose her current state. This is where **Stashing** comes in. ==== Stashing Your Work +tag::procedure[] -To demonstrate stashing, you'll go into your project and start working on a couple of files and possibly stage one of the changes. -If you run `git status`, you can see your dirty state: - -[source,console] ----- -$ git status -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - modified: index.html - -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: lib/simplegit.rb ----- - -Now you want to switch branches, but you don't want to commit what you've been working on yet, so you'll stash the changes. -To push a new stash onto your stack, run `git stash` or `git stash push`: +(((git commands, stash))) +The `git stash` command takes the current state of Priya's working directory—both modified tracked files and staged changes—and saves it on a temporary stack. -[source,console] +[source,bash] ---- $ git stash -Saved working directory and index state \ - "WIP on master: 049d078 Create index file" -HEAD is now at 049d078 Create index file -(To restore them type "git stash apply") +Saved working directory and index state WIP on main: f30ab [Design: Tokens]... ---- -You can now see that your working directory is clean: +Now Priya's working directory is clean. She can switch to the `fix/contrast` branch, do her work, and merge it. -[source,console] ----- -$ git status -# On branch master -nothing to commit, working directory clean ----- +==== Reapplying Your Stash +tag::procedure[] -At this point, you can switch branches and do work elsewhere; your changes are stored on your stack. -To see which stashes you've stored, you can use `git stash list`: +Once the hotfix is done, Priya returns to her illustrations. To get her messy work back, she runs: -[source,console] +[source,bash] ---- -$ git stash list -stash@{0}: WIP on master: 049d078 Create index file -stash@{1}: WIP on master: c264051 Revert "Add file_size" -stash@{2}: WIP on master: 21d80a5 Add number to log +$ git stash pop ---- -In this case, two stashes were saved previously, so you have access to three different stashed works. -You can reapply the one you just stashed by using the command shown in the help output of the original stash command: `git stash apply`. -If you want to apply one of the older stashes, you can specify it by naming it, like this: `git stash apply stash@{2}`. -If you don't specify a stash, Git assumes the most recent stash and tries to apply it: - -[source,console] ----- -$ git stash apply -On branch master -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: index.html - modified: lib/simplegit.rb - -no changes added to commit (use "git add" and/or "git commit -a") ----- +This command reapplies her stashed changes and "pops" them off the stack. Her workspace looks exactly like it did before the interruption. -You can see that Git re-modifies the files you reverted when you saved the stash. -In this case, you had a clean working directory when you tried to apply the stash, and you tried to apply it on the same branch you saved it from. -Having a clean working directory and applying it on the same branch aren't necessary to successfully apply a stash. -You can save a stash on one branch, switch to another branch later, and try to reapply the changes. -You can also have modified and uncommitted files in your working directory when you apply a stash -- Git gives you merge conflicts if anything no longer applies cleanly. +==== Managing Multiple Stashes +tag::reference[] -The changes to your files were reapplied, but the file you staged before wasn't restaged. -To do that, you must run the `git stash apply` command with a `--index` option to tell the command to try to reapply the staged changes. -If you had run that instead, you'd have gotten back to your original position: +If Priya gets interrupted multiple times, she can have several items in her stash. She can see them by running: -[source,console] ----- -$ git stash apply --index -On branch master -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - modified: index.html - -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: lib/simplegit.rb ----- - -The `apply` option only tries to apply the stashed work -- you continue to have it on your stack. -To remove it, you can run `git stash drop` with the name of the stash to remove: - -[source,console] +[source,bash] ---- $ git stash list -stash@{0}: WIP on master: 049d078 Create index file -stash@{1}: WIP on master: c264051 Revert "Add file_size" -stash@{2}: WIP on master: 21d80a5 Add number to log -$ git stash drop stash@{0} -Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43) ----- - -You can also run `git stash pop` to apply the stash and then immediately drop it from your stack. - -==== Creative Stashing - -There are a few stash variants that may also be helpful. -The first option that is quite popular is the `--keep-index` option to the `git stash` command. -This tells Git to not only include all staged content in the stash being created, but simultaneously leave it in the index. - -[source,console] ----- -$ git status -s -M index.html - M lib/simplegit.rb - -$ git stash --keep-index -Saved working directory and index state WIP on master: 1b65b17 added the index file -HEAD is now at 1b65b17 added the index file - -$ git status -s -M index.html ----- - -Another common thing you may want to do with stash is to stash the untracked files as well as the tracked ones. -By default, `git stash` will stash only modified and staged _tracked_ files. -If you specify `--include-untracked` or `-u`, Git will include untracked files in the stash being created. -However, including untracked files in the stash will still not include explicitly _ignored_ files; to additionally include ignored files, use `--all` (or just `-a`). - -[source,console] +stash@{0}: WIP on main: 34ac2 [Design: Results]... +stash@{1}: WIP on main: 98ca9 [Research: Setup]... ---- -$ git status -s -M index.html - M lib/simplegit.rb -?? new-file.txt - -$ git stash -u -Saved working directory and index state WIP on master: 1b65b17 added the index file -HEAD is now at 1b65b17 added the index file - -$ git status -s -$ ----- - -Finally, if you specify the `--patch` flag, Git will not stash everything that is modified but will instead prompt you interactively which of the changes you would like to stash and which you would like to keep in your working directory. -[source,console] ----- -$ git stash --patch -diff --git a/lib/simplegit.rb b/lib/simplegit.rb -index 66d332e..8bb5674 100644 ---- a/lib/simplegit.rb -+++ b/lib/simplegit.rb -@@ -16,6 +16,10 @@ class SimpleGit - return `#{git_cmd} 2>&1`.chomp - end - end -+ -+ def show(treeish = 'master') -+ command("git show #{treeish}") -+ end - - end - test -Stash this hunk [y,n,q,a,d,/,e,?]? y - -Saved working directory and index state WIP on master: 1b65b17 added the index file ----- +She can apply a specific stash (without removing it from the list) using `git stash apply stash@{1}`. -==== Creating a Branch from a Stash +==== Cleaning Up the Workspace +tag::procedure[] -If you stash some work, leave it there for a while, and continue on the branch from which you stashed the work, you may have a problem reapplying the work. -If the apply tries to modify a file that you've since modified, you'll get a merge conflict and will have to try to resolve it. -If you want an easier way to test the stashed changes again, you can run `git stash branch <new branchname>`, which creates a new branch for you with your selected branch name, checks out the commit you were on when you stashed your work, reapplies your work there, and then drops the stash if it applies successfully: +(((git commands, clean))) +After a long week of exporting, Priya's `sketchspark` folder is cluttered with untracked files: `export_v1.png`, `test.svg`, `junk.txt`. She wants to tidy up and remove *everything* that Git isn't tracking. -[source,console] +[source,bash] ---- -$ git stash branch testchanges -M index.html -M lib/simplegit.rb -Switched to a new branch 'testchanges' -On branch testchanges -Changes to be committed: - (use "git reset HEAD <file>..." to unstage) - - modified: index.html - -Changes not staged for commit: - (use "git add <file>..." to update what will be committed) - (use "git checkout -- <file>..." to discard changes in working directory) - - modified: lib/simplegit.rb - -Dropped refs/stash@{0} (29d385a81d163dfd45a452a2ce816487a6b8b014) +$ git clean -f ---- -This is a nice shortcut to recover stashed work easily and work on it in a new branch. - -[[_git_clean]] -==== Cleaning your Working Directory - -Finally, you may not want to stash some work or files in your working directory, but simply get rid of them; that's what the `git clean` command is for. - -Some common reasons for cleaning your working directory might be to remove cruft that has been generated by merges or external tools or to remove build artifacts in order to run a clean build. - -You'll want to be pretty careful with this command, since it's designed to remove files from your working directory that are not tracked. -If you change your mind, there is often no retrieving the content of those files. -A safer option is to run `git stash --all` to remove everything but save it in a stash. - -Assuming you do want to remove cruft files or clean your working directory, you can do so with `git clean`. -To remove all the untracked files in your working directory, you can run `git clean -f -d`, which removes any files and also any subdirectories that become empty as a result. -The `-f` means 'force' or "`really do this,`" and is required if the Git configuration variable `clean.requireForce` is not explicitly set to false. +This command deletes all untracked files in the current directory. -If you ever want to see what it would do, you can run the command with the `--dry-run` (or `-n`) option, which means "`do a dry run and tell me what you _would_ have removed`". - -[source,console] ----- -$ git clean -d -n -Would remove test.o -Would remove tmp/ ----- - -By default, the `git clean` command will only remove untracked files that are not ignored. -Any file that matches a pattern in your `.gitignore` or other ignore files will not be removed. -If you want to remove those files too, such as to remove all `.o` files generated from a build so you can do a fully clean build, you can add a `-x` to the `clean` command. - -[source,console] ----- -$ git status -s - M lib/simplegit.rb -?? build.TMP -?? tmp/ - -$ git clean -n -d -Would remove build.TMP -Would remove tmp/ - -$ git clean -n -d -x -Would remove build.TMP -Would remove test.o -Would remove tmp/ ----- - -If you don't know what the `git clean` command is going to do, always run it with a `-n` first to double check before changing the `-n` to a `-f` and doing it for real. -The other way you can be careful about the process is to run it with the `-i` or "`interactive`" flag. - -This will run the `clean` command in an interactive mode. - -[source,console] ----- -$ git clean -x -i -Would remove the following items: - build.TMP test.o -*** Commands *** - 1: clean 2: filter by pattern 3: select by numbers 4: ask each 5: quit - 6: help -What now> ----- - -This way you can step through each file individually or specify patterns for deletion interactively. - -[NOTE] +[CAUTION] ==== -There is a quirky situation where you might need to be extra forceful in asking Git to clean your working directory. -If you happen to be in a working directory under which you've copied or cloned other Git repositories (perhaps as submodules), even `git clean -fd` will refuse to delete those directories. -In cases like that, you need to add a second `-f` option for emphasis. +`git clean -f` is a destructive command. Once those files are gone, they are gone forever. Always run `git clean -n` first to see a "dry run" of what will be deleted. ==== + +By mastering stashing and cleaning, Priya ensures her workspace always matches her current focus, allowing her to handle interruptions gracefully without cluttering the project's history. diff --git a/book/08-customizing-git/sections/attributes.asc b/book/08-customizing-git/sections/attributes.asc index cbcad3631..67b7e59f2 100644 --- a/book/08-customizing-git/sections/attributes.asc +++ b/book/08-customizing-git/sections/attributes.asc @@ -1,377 +1,82 @@ +[[_git_attributes]] === Git Attributes +tag::concept[] -(((attributes))) -Some of these settings can also be specified for a path, so that Git applies those settings only for a subdirectory or subset of files. -These path-specific settings are called Git attributes and are set either in a `.gitattributes` file in one of your directories (normally the root of your project) or in the `.git/info/attributes` file if you don't want the attributes file committed with your project. +(((git commands, .gitattributes))) +While `git config` allows you to customize your local environment, the **`.gitattributes`** file allows Nora to customize how Git treats specific files *inside the project*. Because this file is committed to the repository, those customizations are shared with everyone on the SketchSpark team. -Using attributes, you can do things like specify separate merge strategies for individual files or directories in your project, tell Git how to diff non-text files, or have Git filter content before you check it into or out of Git. -In this section, you'll learn about some of the attributes you can set on your paths in your Git project and see a few examples of using this feature in practice. - -==== Binary Files +#### Binary Files +tag::config[] (((binary files))) -One cool trick for which you can use Git attributes is telling Git which files are binary (in cases it otherwise may not be able to figure out) and giving Git special instructions about how to handle those files. -For instance, some text files may be machine generated and not diffable, whereas some binary files can be diffed. -You'll see how to tell Git which is which. - -===== Identifying Binary Files - -Some files look like text files but for all intents and purposes are to be treated as binary data. -For instance, Xcode projects on macOS contain a file that ends in `.pbxproj`, which is basically a JSON (plain-text JavaScript data format) dataset written out to disk by the IDE, which records your build settings and so on. -Although it's technically a text file (because it's all UTF-8), you don't want to treat it as such because it's really a lightweight database – you can't merge the contents if two people change it, and diffs generally aren't helpful. -The file is meant to be consumed by a machine. -In essence, you want to treat it like a binary file. - -To tell Git to treat all `pbxproj` files as binary data, add the following line to your `.gitattributes` file: - -[source,ini] ----- -*.pbxproj binary ----- - -Now, Git won't try to convert or fix CRLF issues; nor will it try to compute or print a diff for changes in this file when you run `git show` or `git diff` on your project. - -===== Diffing Binary Files - -You can also use the Git attributes functionality to effectively diff binary files. -You do this by telling Git how to convert your binary data to a text format that can be compared via the normal diff. - -First, you'll use this technique to solve one of the most annoying problems known to humanity: version-controlling Microsoft Word documents. -If you want to version-control Word documents, you can stick them in a Git repository and commit every once in a while; but what good does that do? -If you run `git diff` normally, you only see something like this: - -[source,console] ----- -$ git diff -diff --git a/chapter1.docx b/chapter1.docx -index 88839c4..4afcb7c 100644 -Binary files a/chapter1.docx and b/chapter1.docx differ ----- - -You can't directly compare two versions unless you check them out and scan them manually, right? -It turns out you can do this fairly well using Git attributes. -Put the following line in your `.gitattributes` file: +Git is great at handling text, but design projects are full of **binary files**—PNGs, SVGs, and Sketch files. By default, Git treats everything as a potential text file. Nora uses `.gitattributes` to tell Git which files should be treated as binary: [source,ini] ---- -*.docx diff=word ----- - -This tells Git that any file that matches this pattern (`.docx`) should use the "`word`" filter when you try to view a diff that contains changes. -What is the "`word`" filter? -You have to set it up. -Here you'll configure Git to use the `docx2txt` program to convert Word documents into readable text files, which it will then diff properly. - -First, you'll need to install `docx2txt`; you can download it from https://sourceforge.net/projects/docx2txt[^]. -Follow the instructions in the `INSTALL` file to put it somewhere your shell can find it. -Next, you'll write a wrapper script to convert output to the format Git expects. -Create a file that's somewhere in your path called `docx2txt`, and add these contents: - -[source,console] ----- -#!/bin/bash -docx2txt.pl "$1" - +*.png binary +*.jpg binary +*.sketch binary ---- -Don't forget to `chmod a+x` that file. -Finally, you can configure Git to use this script: +This prevents Git from trying to "fix" line endings or perform text-based merges on these files, which would corrupt them. -[source,console] ----- -$ git config diff.word.textconv docx2txt ----- - -Now Git knows that if it tries to do a diff between two snapshots, and any of the files end in `.docx`, it should run those files through the "`word`" filter, which is defined as the `docx2txt` program. -This effectively makes nice text-based versions of your Word files before attempting to diff them. - -Here's an example: Chapter 1 of this book was converted to Word format and committed in a Git repository. -Then a new paragraph was added. -Here's what `git diff` shows: - -[source,console] ----- -$ git diff -diff --git a/chapter1.docx b/chapter1.docx -index 0b013ca..ba25db5 100644 ---- a/chapter1.docx -+++ b/chapter1.docx -@@ -2,6 +2,7 @@ - This chapter will be about getting started with Git. We will begin at the beginning by explaining some background on version control tools, then move on to how to get Git running on your system and finally how to get it setup to start working with. At the end of this chapter you should understand why Git is around, why you should use it and you should be all setup to do so. - 1.1. About Version Control - What is "version control", and why should you care? Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. For the examples in this book you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer. -+Testing: 1, 2, 3. - If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if you screw things up or lose files, you can easily recover. In addition, you get all this for very little overhead. - 1.1.1. Local Version Control Systems - Many people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever). This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to. ----- +#### Visual Diffing for Designers +tag::procedure[] -Git successfully and succinctly tells us that we added the string "`Testing: 1, 2, 3.`", which is correct. -It's not perfect – formatting changes wouldn't show up here – but it certainly works. +(((diffing, images))) +When Nora runs `git diff` on a modified PNG, Git usually just says: `Binary files differ`. This isn't helpful for a design review. -Another interesting problem you can solve this way involves diffing image files. -One way to do this is to run image files through a filter that extracts their EXIF information – metadata that is recorded with most image formats. -If you download and install the `exiftool` program, you can use it to convert your images into text about the metadata, so at least the diff will show you a textual representation of any changes that happened. -Put the following line in your `.gitattributes` file: +She can configure Git to use an external **Visual Diff Tool** for images. For example, she can use a script that converts the image metadata (dimensions, colors) into text, or a tool that opens both versions in a side-by-side viewer. [source,ini] ---- *.png diff=exif ---- -Configure Git to use this tool: - -[source,console] ----- -$ git config diff.exif.textconv exiftool ----- - -If you replace an image in your project and run `git diff`, you see something like this: - -[source,diff] ----- -diff --git a/image.png b/image.png -index 88839c4..4afcb7c 100644 ---- a/image.png -+++ b/image.png -@@ -1,12 +1,12 @@ - ExifTool Version Number : 7.74 --File Size : 70 kB --File Modification Date/Time : 2009:04:21 07:02:45-07:00 -+File Size : 94 kB -+File Modification Date/Time : 2009:04:21 07:02:43-07:00 - File Type : PNG - MIME Type : image/png --Image Width : 1058 --Image Height : 889 -+Image Width : 1056 -+Image Height : 827 - Bit Depth : 8 - Color Type : RGB with Alpha ----- - -You can easily see that the file size and image dimensions have both changed. - -[[_keyword_expansion]] -==== Keyword Expansion - -(((keyword expansion))) -SVN- or CVS-style keyword expansion is often requested by developers used to those systems. -The main problem with this in Git is that you can't modify a file with information about the commit after you've committed, because Git checksums the file first. -However, you can inject text into a file when it's checked out and remove it again before it's added to a commit. -Git attributes offers you two ways to do this. - -First, you can inject the SHA-1 checksum of a blob into an `$Id$` field in the file automatically. -If you set this attribute on a file or set of files, then the next time you check out that branch, Git will replace that field with the SHA-1 of the blob. -It's important to notice that it isn't the SHA-1 of the commit, but of the blob itself. -Put the following line in your `.gitattributes` file: - -[source,ini] ----- -*.txt ident ----- - -Add an `$Id$` reference to a test file: - -[source,console] ----- -$ echo '$Id$' > test.txt ----- - -The next time you check out this file, Git injects the SHA-1 of the blob: - -[source,console] ----- -$ rm test.txt -$ git checkout -- test.txt -$ cat test.txt -$Id: 42812b7653c7b88933f8a9d6cad0ca16714b9bb3 $ ----- - -However, that result is of limited use. -If you've used keyword substitution in CVS or Subversion, you can include a datestamp – the SHA-1 isn't all that helpful, because it's fairly random and you can't tell if one SHA-1 is older or newer than another just by looking at them. - -It turns out that you can write your own filters for doing substitutions in files on commit/checkout. -These are called "`clean`" and "`smudge`" filters. -In the `.gitattributes` file, you can set a filter for particular paths and then set up scripts that will process files just before they're checked out ("`smudge`", see <<filters_a>>) and just before they're staged ("`clean`", see <<filters_b>>). -These filters can be set to do all sorts of fun things. - -[[filters_a]] -.The "`smudge`" filter is run on checkout -image::images/smudge.png[The “smudge” filter is run on checkout] - -[[filters_b]] -.The "`clean`" filter is run when files are staged -image::images/clean.png[The “clean” filter is run when files are staged] +Then, in her `.gitconfig`, she defines what "exif" diffing means (using the `exiftool` command to show image metadata changes): -The original commit message for this feature gives a simple example of running all your C source code through the `indent` program before committing. -You can set it up by setting the filter attribute in your `.gitattributes` file to filter `\*.c` files with the "`indent`" filter: - -[source,ini] +[source,bash] ---- -*.c filter=indent +$ git config --global diff.exif.textconv exiftool ---- -Then, tell Git what the "`indent`" filter does on smudge and clean: +Now, when Sam changes the resolution of an icon, Nora’s `git diff` will actually show the resolution change in text! -[source,console] ----- -$ git config --global filter.indent.clean indent -$ git config --global filter.indent.smudge cat ----- +#### Managing Large Assets with Git LFS +tag::concept[] -In this case, when you commit files that match `*.c`, Git will run them through the indent program before it stages them and then run them through the `cat` program before it checks them back out onto disk. -The `cat` program does essentially nothing: it spits out the same data that it comes in. -This combination effectively filters all C source code files through `indent` before committing. +(((Git LFS))) +As the SketchSpark team adds hundreds of high-fidelity illustrations, the repository size could explode, making `git clone` painfully slow. To solve this, Nora uses **Git LFS (Large File Storage)**. -Another interesting example gets `$Date$` keyword expansion, RCS style. -To do this properly, you need a small script that takes a filename, figures out the last commit date for this project, and inserts the date into the file. -Here is a small Ruby script that does that: - -[source,ruby] ----- -#! /usr/bin/env ruby -data = STDIN.read -last_date = `git log --pretty=format:"%ad" -1` -puts data.gsub('$Date$', '$Date: ' + last_date.to_s + '$') ----- +Git LFS replaces large files in the repository with tiny "pointer" files. The actual assets are stored on a separate LFS server (most Git hosts, including GitHub, support this automatically). -All the script does is get the latest commit date from the `git log` command, stick that into any `$Date$` strings it sees in stdin, and print the results – it should be simple to do in whatever language you're most comfortable in. -You can name this file `expand_date` and put it in your path. -Now, you need to set up a filter in Git (call it `dater`) and tell it to use your `expand_date` filter to smudge the files on checkout. -You'll use a Perl expression to clean that up on commit: +To start using LFS, Nora installs the LFS extension and then "tracks" her large file types: -[source,console] +[source,bash] ---- -$ git config filter.dater.smudge expand_date -$ git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"' +$ git lfs install +$ git lfs track "*.psd" +$ git lfs track "*.mp4" ---- -This Perl snippet strips out anything it sees in a `$Date$` string, to get back to where you started. -Now that your filter is ready, you can test it by setting up a Git attribute for that file that engages the new filter and creating a file with your `$Date$` keyword: - +This adds new entries to her `.gitattributes` file: [source,ini] ---- -date*.txt filter=dater ----- - -[source,console] ----- -$ echo '# $Date$' > date_test.txt ----- - -If you commit those changes and check out the file again, you see the keyword properly substituted: - -[source,console] ----- -$ git add date_test.txt .gitattributes -$ git commit -m "Test date expansion in Git" -$ rm date_test.txt -$ git checkout date_test.txt -$ cat date_test.txt -# $Date: Tue Apr 21 07:26:52 2009 -0700$ +*.psd filter=lfs diff=lfs merge=lfs -text ---- -You can see how powerful this technique can be for customized applications. -You have to be careful, though, because the `.gitattributes` file is committed and passed around with the project, but the driver (in this case, `dater`) isn't, so it won't work everywhere. -When you design these filters, they should be able to fail gracefully and have the project still work properly. +Now, the `sketchspark` repo stays lightweight and fast, even as the team’s library of high-res assets grows. -==== Exporting Your Repository +#### Exporting Assets +tag::config[] (((archiving))) -Git attribute data also allows you to do some interesting things when exporting an archive of your project. - -===== `export-ignore` - -You can tell Git not to export certain files or directories when generating an archive. -If there is a subdirectory or file that you don't want to include in your archive file but that you do want checked into your project, you can determine those files via the `export-ignore` attribute. - -For example, say you have some test files in a `test/` subdirectory, and it doesn't make sense to include them in the tarball export of your project. -You can add the following line to your Git attributes file: - -[source,ini] ----- -test/ export-ignore ----- - -Now, when you run `git archive` to create a tarball of your project, that directory won't be included in the archive. - -===== `export-subst` - -When exporting files for deployment you can apply ``git log```'s formatting and keyword-expansion processing to selected portions of files marked with the ``export-subst`` attribute. - -For instance, if you want to include a file named `LAST_COMMIT` in your project, and have metadata about the last commit automatically injected into it when `git archive` runs, you can for example set up your `.gitattributes` and `LAST_COMMIT` files like this: +When Nora generates a "Snapshot" of the project for a client using `git archive`, she doesn't want to include her internal research notes or testing scripts. She can use the `export-ignore` attribute: [source,ini] ---- -LAST_COMMIT export-subst ----- - -[source,console] ----- -$ echo 'Last commit date: $Format:%cd by %aN$' > LAST_COMMIT -$ git add LAST_COMMIT .gitattributes -$ git commit -am 'adding LAST_COMMIT file for archives' ----- - -When you run `git archive`, the contents of the archived file will look like this: - -[source,console] ----- -$ git archive HEAD | tar xCf ../deployment-testing - -$ cat ../deployment-testing/LAST_COMMIT -Last commit date: Tue Apr 21 08:38:48 2009 -0700 by Scott Chacon ----- - -The substitutions can include for example the commit message and any `git notes`, and `git log` can do simple word wrapping: - -[source,console] ----- -$ echo '$Format:Last commit: %h by %aN at %cd%n%+w(76,6,9)%B$' > LAST_COMMIT -$ git commit -am 'export-subst uses git log'\''s custom formatter - -git archive uses git log'\''s `pretty=format:` processor -directly, and strips the surrounding `$Format:` and `$` -markup from the output. -' -$ git archive @ | tar xfO - LAST_COMMIT -Last commit: 312ccc8 by Jim Hill at Fri May 8 09:14:04 2015 -0700 - export-subst uses git log's custom formatter - - git archive uses git log's `pretty=format:` processor directly, and - strips the surrounding `$Format:` and `$` markup from the output. ----- - -The resulting archive is suitable for deployment work, but like any exported archive it isn't suitable for further development work. - -==== Merge Strategies - -(((merging, strategies))) -You can also use Git attributes to tell Git to use different merge strategies for specific files in your project. -One very useful option is to tell Git to not try to merge specific files when they have conflicts, but rather to use your side of the merge over someone else's. - -This is helpful if a branch in your project has diverged or is specialized, but you want to be able to merge changes back in from it, and you want to ignore certain files. -Say you have a database settings file called `database.xml` that is different in two branches, and you want to merge in your other branch without messing up the database file. -You can set up an attribute like this: - -[source,ini] ----- -database.xml merge=ours ----- - -And then define a dummy `ours` merge strategy with: - -[source,console] ----- -$ git config --global merge.ours.driver true ----- - -If you merge in the other branch, instead of having merge conflicts with the `database.xml` file, you see something like this: - -[source,console] ----- -$ git merge topic -Auto-merging database.xml -Merge made by recursive. +research/ export-ignore +scripts/ export-ignore ---- -In this case, `database.xml` stays at whatever version you originally had. +By mastering Git Attributes, Nora ensures that the SketchSpark repository is perfectly tuned for the unique needs of a design-centric project, handling everything from tiny icons to massive source files with ease. diff --git a/book/08-customizing-git/sections/config.asc b/book/08-customizing-git/sections/config.asc index 16739692f..f40caf1c4 100644 --- a/book/08-customizing-git/sections/config.asc +++ b/book/08-customizing-git/sections/config.asc @@ -1,517 +1,95 @@ [[_git_config]] === Git Configuration +tag::concept[] (((git commands, config))) -As you read briefly in <<ch01-getting-started#ch01-getting-started>>, you can specify Git configuration settings with the `git config` command. -One of the first things you did was set up your name and email address: +As you learned in Chapter 1, you can customize how Git looks and behaves using the `git config` command. For Nora and the SketchSpark team, this isn't just about aesthetics—it's about making the command line a supportive tool for their design process. -[source,console] ----- -$ git config --global user.name "John Doe" -$ git config --global user.email johndoe@example.com ----- - -Now you'll learn a few of the more interesting options that you can set in this manner to customize your Git usage. - -First, a quick review: Git uses a series of configuration files to determine non-default behavior that you may want. -The first place Git looks for these values is in the system-wide `[path]/etc/gitconfig` file, which contains settings that are applied to every user on the system and all of their repositories. -If you pass the option `--system` to `git config`, it reads and writes from this file specifically. - -The next place Git looks is the `~/.gitconfig` (or `~/.config/git/config`) file, which is specific to each user. -You can make Git read and write to this file by passing the `--global` option. - -Finally, Git looks for configuration values in the configuration file in the Git directory (`.git/config`) of whatever repository you're currently using. -These values are specific to that single repository, and represent passing the `--local` option to `git config`. -If you don't specify which level you want to work with, this is the default. - -Each of these "`levels`" (system, global, local) overwrites values in the previous level, so values in `.git/config` trump those in `[path]/etc/gitconfig`, for instance. - -[NOTE] -==== -Git's configuration files are plain-text, so you can also set these values by manually editing the file and inserting the correct syntax. -It's generally easier to run the `git config` command, though. -==== +Git stores these settings in three different levels: +1. **System (`--system`):** Applied to every user on the computer. +2. **Global (`--global`):** Applied to every repository you work on (Nora's primary tool). +3. **Local (`--local`):** Applied only to the current project (the default). ==== Basic Client Configuration +tag::procedure[] -The configuration options recognized by Git fall into two categories: client-side and server-side. -The majority of the options are client-side -- configuring your personal working preferences. -Many, _many_ configuration options are supported, but a large fraction of them are useful only in certain edge cases; we'll cover just the most common and useful options here. -If you want to see a list of all the options your version of Git recognizes, you can run: - -[source,console] ----- -$ man git-config ----- - -This command lists all the available options in quite a bit of detail. -You can also find this reference material at https://git-scm.com/docs/git-config[^]. - -[NOTE] -==== -For advanced use cases you may want to look up "Conditional includes" in the documentation mentioned above. -==== - -===== `core.editor` +Nora can tweak many settings to fit her "power designer" workflow. -((($EDITOR)))((($VISUAL, see $EDITOR))) -By default, Git uses whatever you've set as your default text editor via one of the shell environment variables `VISUAL` or `EDITOR`, or else falls back to the `vi` editor to create and edit your commit and tag messages. -To change that default to something else, you can use the `core.editor` setting: +===== Custom Editor +If Nora prefers using a specific text editor for her commit messages (like VS Code), she can set it globally: -[source,console] +[source,bash] ---- -$ git config --global core.editor emacs +$ git config --global core.editor "code --wait" ---- -Now, no matter what is set as your default shell editor, Git will fire up Emacs to edit messages. - -===== `commit.template` +===== Commit Templates +tag::procedure[] (((commit templates))) -If you set this to the path of a file on your system, Git will use that file as the default initial message when you commit. -The value in creating a custom commit template is that you can use it to remind yourself (or others) of the proper format and style when creating a commit message. - -For instance, consider a template file at `~/.gitmessage.txt` that looks like this: +To ensure everyone follows the `[Phase: Component]` convention, Nora sets up a **commit template**. She creates a file named `~/.gitmessage.txt`: [source,text] ---- -Subject line (try to keep under 50 characters) - -Multi-line description of commit, -feel free to be detailed. +[Phase: Component] Short summary (keep under 50 chars) -[Ticket: X] +Detailed explanation of why this change was made. +Mention any related Figma pages or research notes. ---- -Note how this commit template reminds the committer to keep the subject line short (for the sake of `git log --oneline` output), to add further detail under that, and to refer to an issue or bug tracker ticket number if one exists. +Then she tells Git to use it: -To tell Git to use it as the default message that appears in your editor when you run `git commit`, set the `commit.template` configuration value: - -[source,console] +[source,bash] ---- $ git config --global commit.template ~/.gitmessage.txt -$ git commit ---- -Then, your editor will open to something like this for your placeholder commit message when you commit: +Now, every time Sam or Priya runs `git commit`, their editor will open with this helpful reminder already filled in. -[source,text] ----- -Subject line (try to keep under 50 characters) +===== Global Ignore Patterns +tag::config[] -Multi-line description of commit, -feel free to be detailed. - -[Ticket: X] -# Please enter the commit message for your changes. Lines starting -# with '#' will be ignored, and an empty message aborts the commit. -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# modified: lib/test.rb -# -~ -~ -".git/COMMIT_EDITMSG" 14L, 297C ----- - -If your team has a commit-message policy, then putting a template for that policy on your system and configuring Git to use it by default can help increase the chance of that policy being followed regularly. - -===== `core.pager` - -(((pager))) -This setting determines which pager is used when Git pages output such as `log` and `diff`. -You can set it to `more` or to your favorite pager (by default, it's `less`), or you can turn it off by setting it to a blank string: - -[source,console] ----- -$ git config --global core.pager '' ----- - -If you run that, Git will print the entire output of all commands, no matter how long they are. - -===== `user.signingkey` - -(((GPG))) -If you're making signed annotated tags (as discussed in <<ch07-git-tools#_signing>>), setting your GPG signing key as a configuration setting makes things easier. -Set your key ID like so: +(((excludes)))(((.gitignore))) +Every design tool creates temporary "junk" files (like `.DS_Store` on macOS or `*.sketch~` backup files). Instead of adding these to every single project's `.gitignore`, Nora creates a **global ignores file**. -[source,console] +She creates `~/.gitignore_global`: +[source,text] ---- -$ git config --global user.signingkey <gpg-key-id> +.DS_Store +*.sketch~ +*.figma_cache ---- -Now, you can sign tags without having to specify your key every time with the `git tag` command: - -[source,console] +And configures Git to use it: +[source,bash] ---- -$ git tag -s <tag-name> +$ git config --global core.excludesfile ~/.gitignore_global ---- -===== `core.excludesfile` - -(((excludes)))(((.gitignore))) -You can put patterns in your project's `.gitignore` file to have Git not see them as untracked files or try to stage them when you run `git add` on them, as discussed in <<ch02-git-basics-chapter#_ignoring>>. - -But sometimes you want to ignore certain files for all repositories that you work with. -If your computer is running macOS, you're probably familiar with `.DS_Store` files. -If your preferred editor is Emacs or Vim, you know about filenames that end with a `~` or `.swp`. - -This setting lets you write a kind of global `.gitignore` file. -If you create a `~/.gitignore_global` file with these contents: - -[source,ini] ----- -*~ -.*.swp -.DS_Store ----- +Now, Git will ignore these files in *every* repository Nora ever works on. -…and you run `git config --global core.excludesfile ~/.gitignore_global`, Git will never again bother you about those files. - -===== `help.autocorrect` +===== Autocorrect +tag::config[] (((autocorrect))) -If you mistype a command, it shows you something like this: - -[source,console] ----- -$ git chekcout master -git: 'chekcout' is not a git command. See 'git --help'. - -The most similar command is - checkout ----- - -Git helpfully tries to figure out what you meant, but it still refuses to do it. -If you set `help.autocorrect` to 1, Git will actually run this command for you: +If Nora mistypes a command—like `git chekcout`—Git usually just gives an error. By enabling autocorrect, she can tell Git to just do what she meant: -[source,console] +[source,bash] ---- -$ git chekcout master -WARNING: You called a Git command named 'chekcout', which does not exist. -Continuing under the assumption that you meant 'checkout' -in 0.1 seconds automatically... +$ git config --global help.autocorrect 30 ---- -Note that "`0.1 seconds`" business. -`help.autocorrect` is actually an integer which represents tenths of a second. -So if you set it to 50, Git will give you 5 seconds to change your mind before executing the autocorrected command. +The number `30` tells Git to wait 3 seconds (30 tenths of a second) before automatically executing the corrected command. It’s a small tweak that makes the CLI feel much more forgiving. ==== Colors in Git +tag::config[] (((color))) -Git fully supports colored terminal output, which greatly aids in visually parsing command output quickly and easily. -A number of options can help you set the coloring to your preference. - -===== `color.ui` - -Git automatically colors most of its output, but there's a master switch if you don't like this behavior. -To turn off all Git's colored terminal output, do this: - -[source,console] ----- -$ git config --global color.ui false ----- - -The default setting is `auto`, which colors output when it's going straight to a terminal, but omits the color-control codes when the output is redirected to a pipe or a file. - -You can also set it to `always` to ignore the difference between terminals and pipes. -You'll rarely want this; in most scenarios, if you want color codes in your redirected output, you can instead pass a `--color` flag to the Git command to force it to use color codes. -The default setting is almost always what you'll want. - -===== `color.*` - -If you want to be more specific about which commands are colored and how, Git provides verb-specific coloring settings. -Each of these can be set to `true`, `false`, or `always`: - - color.branch - color.diff - color.interactive - color.status - -In addition, each of these has subsettings you can use to set specific colors for parts of the output, if you want to override each color. -For example, to set the meta information in your diff output to blue foreground, black background, and bold text, you can run: - -[source,console] ----- -$ git config --global color.diff.meta "blue black bold" ----- - -You can set the color to any of the following values: `normal`, `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, or `white`. -If you want an attribute like bold in the previous example, you can choose from `bold`, `dim`, `ul` (underline), `blink`, and `reverse` (swap foreground and background). - -[[_external_merge_tools]] -==== External Merge and Diff Tools - -(((mergetool)))(((difftool))) -Although Git has an internal implementation of diff, which is what we've been showing in this book, you can set up an external tool instead. -You can also set up a graphical merge-conflict-resolution tool instead of having to resolve conflicts manually. -We'll demonstrate setting up the Perforce Visual Merge Tool (P4Merge) to do your diffs and merge resolutions, because it's a nice graphical tool and it's free. - -If you want to try this out, P4Merge works on all major platforms, so you should be able to do so. -We'll use path names in the examples that work on macOS and Linux systems; for Windows, you'll have to change `/usr/local/bin` to an executable path in your environment. - -To begin, https://www.perforce.com/products/helix-core-apps/merge-diff-tool-p4merge[download P4Merge from Perforce^]. -Next, you'll set up external wrapper scripts to run your commands. -We'll use the macOS path for the executable; in other systems, it will be where your `p4merge` binary is installed. -Set up a merge wrapper script named `extMerge` that calls your binary with all the arguments provided: - -[source,console] ----- -$ cat /usr/local/bin/extMerge -#!/bin/sh -/Applications/p4merge.app/Contents/MacOS/p4merge $* ----- - -The diff wrapper checks to make sure seven arguments are provided and passes two of them to your merge script. -By default, Git passes the following arguments to the diff program: - -[source] ----- -path old-file old-hex old-mode new-file new-hex new-mode ----- - -Because you only want the `old-file` and `new-file` arguments, you use the wrapper script to pass the ones you need. - -[source,console] ----- -$ cat /usr/local/bin/extDiff -#!/bin/sh -[ $# -eq 7 ] && /usr/local/bin/extMerge "$2" "$5" ----- - -You also need to make sure these tools are executable: - -[source,console] ----- -$ sudo chmod +x /usr/local/bin/extMerge -$ sudo chmod +x /usr/local/bin/extDiff ----- - -Now you can set up your config file to use your custom merge resolution and diff tools. -This takes a number of custom settings: `merge.tool` to tell Git what strategy to use, `mergetool.<tool>.cmd` to specify how to run the command, `mergetool.<tool>.trustExitCode` to tell Git if the exit code of that program indicates a successful merge resolution or not, and `diff.external` to tell Git what command to run for diffs. -So, you can either run four config commands: - -[source,console] ----- -$ git config --global merge.tool extMerge -$ git config --global mergetool.extMerge.cmd \ - 'extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"' -$ git config --global mergetool.extMerge.trustExitCode false -$ git config --global diff.external extDiff ----- - -or you can edit your `~/.gitconfig` file to add these lines: - -[source,ini] ----- -[merge] - tool = extMerge -[mergetool "extMerge"] - cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED" - trustExitCode = false -[diff] - external = extDiff ----- - -After all this is set, if you run diff commands such as this: - -[source,console] ----- -$ git diff 32d1776b1^ 32d1776b1 ----- - -Instead of getting the diff output on the command line, Git fires up P4Merge, which looks something like this: - -.P4Merge -image::images/p4merge.png[P4Merge] - -If you try to merge two branches and subsequently have merge conflicts, you can run the command `git mergetool`; it starts P4Merge to let you resolve the conflicts through that GUI tool. - -The nice thing about this wrapper setup is that you can change your diff and merge tools easily. -For example, to change your `extDiff` and `extMerge` tools to run the KDiff3 tool instead, all you have to do is edit your `extMerge` file: - -[source,console] ----- -$ cat /usr/local/bin/extMerge -#!/bin/sh -/Applications/kdiff3.app/Contents/MacOS/kdiff3 $* ----- - -Now, Git will use the KDiff3 tool for diff viewing and merge conflict resolution. - -Git comes preset to use a number of other merge-resolution tools without your having to set up the cmd configuration. -To see a list of the tools it supports, try this: - -[source,console] ----- -$ git mergetool --tool-help -'git mergetool --tool=<tool>' may be set to one of the following: - emerge - gvimdiff - gvimdiff2 - opendiff - p4merge - vimdiff - vimdiff2 - -The following tools are valid, but not currently available: - araxis - bc3 - codecompare - deltawalker - diffmerge - diffuse - ecmerge - kdiff3 - meld - tkdiff - tortoisemerge - xxdiff - -Some of the tools listed above only work in a windowed -environment. If run in a terminal-only session, they will fail. ----- - -If you're not interested in using KDiff3 for diff but rather want to use it just for merge resolution, and the kdiff3 command is in your path, then you can run: - -[source,console] ----- -$ git config --global merge.tool kdiff3 ----- - -If you run this instead of setting up the `extMerge` and `extDiff` files, Git will use KDiff3 for merge resolution and the normal Git diff tool for diffs. - -==== Formatting and Whitespace - -(((whitespace))) -Formatting and whitespace issues are some of the more frustrating and subtle problems that many developers encounter when collaborating, especially cross-platform. -It's very easy for patches or other collaborated work to introduce subtle whitespace changes because editors silently introduce them, and if your files ever touch a Windows system, their line endings might be replaced. -Git has a few configuration options to help with these issues. - -===== `core.autocrlf` - -(((crlf)))(((line endings))) -If you're programming on Windows and working with people who are not (or vice-versa), you'll probably run into line-ending issues at some point. -This is because Windows uses both a carriage-return character and a linefeed character for newlines in its files, whereas macOS and Linux systems use only the linefeed character. -This is a subtle but incredibly annoying fact of cross-platform work; many editors on Windows silently replace existing LF-style line endings with CRLF, or insert both line-ending characters when the user hits the enter key. - -Git can handle this by auto-converting CRLF line endings into LF when you add a file to the index, and vice versa when it checks out code onto your filesystem. -You can turn on this functionality with the `core.autocrlf` setting. -If you're on a Windows machine, set it to `true` -- this converts LF endings into CRLF when you check out code: - -[source,console] ----- -$ git config --global core.autocrlf true ----- - -If you're on a Linux or macOS system that uses LF line endings, then you don't want Git to automatically convert them when you check out files; however, if a file with CRLF endings accidentally gets introduced, then you may want Git to fix it. -You can tell Git to convert CRLF to LF on commit but not the other way around by setting `core.autocrlf` to `input`: - -[source,console] ----- -$ git config --global core.autocrlf input ----- - -This setup should leave you with CRLF endings in Windows checkouts, but LF endings on macOS and Linux systems and in the repository. - -If you're a Windows programmer doing a Windows-only project, then you can turn off this functionality, recording the carriage returns in the repository by setting the config value to `false`: - -[source,console] ----- -$ git config --global core.autocrlf false ----- - -===== `core.whitespace` - -Git comes preset to detect and fix some whitespace issues. -It can look for six primary whitespace issues -- three are enabled by default and can be turned off, and three are disabled by default but can be activated. - -The three that are turned on by default are `blank-at-eol`, which looks for spaces at the end of a line; `blank-at-eof`, which notices blank lines at the end of a file; and `space-before-tab`, which looks for spaces before tabs at the beginning of a line. - -The three that are disabled by default but can be turned on are `indent-with-non-tab`, which looks for lines that begin with spaces instead of tabs (and is controlled by the `tabwidth` option); `tab-in-indent`, which watches for tabs in the indentation portion of a line; and `cr-at-eol`, which tells Git that carriage returns at the end of lines are OK. - -You can tell Git which of these you want enabled by setting `core.whitespace` to the values you want on or off, separated by commas. -You can disable an option by prepending a `-` in front of its name, or use the default value by leaving it out of the setting string entirely. -For example, if you want all but `space-before-tab` to be set, you can do this (with `trailing-space` being a short-hand to cover both `blank-at-eol` and `blank-at-eof`): - -[source,console] ----- -$ git config --global core.whitespace \ - trailing-space,-space-before-tab,indent-with-non-tab,tab-in-indent,cr-at-eol ----- - -Or you can specify the customizing part only: - -[source,console] ----- -$ git config --global core.whitespace \ - -space-before-tab,indent-with-non-tab,tab-in-indent,cr-at-eol ----- - -Git will detect these issues when you run a `git diff` command and try to color them so you can possibly fix them before you commit. -It will also use these values to help you when you apply patches with `git apply`. -When you're applying patches, you can ask Git to warn you if it's applying patches with the specified whitespace issues: - -[source,console] ----- -$ git apply --whitespace=warn <patch> ----- - -Or you can have Git try to automatically fix the issue before applying the patch: - -[source,console] ----- -$ git apply --whitespace=fix <patch> ----- - -These options apply to the `git rebase` command as well. -If you've committed whitespace issues but haven't yet pushed upstream, you can run `git rebase --whitespace=fix` to have Git automatically fix whitespace issues as it's rewriting the patches. - -==== Server Configuration - -Not nearly as many configuration options are available for the server side of Git, but there are a few interesting ones you may want to take note of. - -===== `receive.fsckObjects` - -Git is capable of making sure every object received during a push still matches its SHA-1 checksum and points to valid objects. -However, it doesn't do this by default; it's a fairly expensive operation, and might slow down the operation, especially on large repositories or pushes. -If you want Git to check object consistency on every push, you can force it to do so by setting `receive.fsckObjects` to true: - -[source,console] ----- -$ git config --system receive.fsckObjects true ----- - -Now, Git will check the integrity of your repository before each push is accepted to make sure faulty (or malicious) clients aren't introducing corrupt data. - -===== `receive.denyNonFastForwards` - -If you rebase commits that you've already pushed and then try to push again, or otherwise try to push a commit to a remote branch that doesn't contain the commit that the remote branch currently points to, you'll be denied. -This is generally good policy; but in the case of the rebase, you may determine that you know what you're doing and can force-update the remote branch with a `-f` flag to your push command. - -To tell Git to refuse force-pushes, set `receive.denyNonFastForwards`: - -[source,console] ----- -$ git config --system receive.denyNonFastForwards true ----- - -The other way you can do this is via server-side receive hooks, which we'll cover in a bit. -That approach lets you do more complex things like deny non-fast-forwards to a certain subset of users. - -===== `receive.denyDeletes` - -One of the workarounds to the `denyNonFastForwards` policy is for the user to delete the branch and then push it back up with the new reference. -To avoid this, set `receive.denyDeletes` to true: +Nora wants her terminal to be as visual as her designs. Git colors its output by default (`color.ui = auto`), but she can customize specific colors (like making `branch` names a vibrant purple) to help her parse history faster. -[source,console] +[source,bash] ---- -$ git config --system receive.denyDeletes true +$ git config --global color.branch.current "purple bold" ---- -This denies any deletion of branches or tags -- no user can do it. -To remove remote branches, you must remove the ref files from the server manually. -There are also more interesting ways to do this on a per-user basis via ACLs, as you'll learn in <<ch08-customizing-git#_an_example_git_enforced_policy>>. +By mastering these configuration tools, Nora and her team turn Git into a customized workspace that respects their conventions and reduces friction in their daily workflow. diff --git a/book/08-customizing-git/sections/hooks.asc b/book/08-customizing-git/sections/hooks.asc index 285ba4ffa..a4c5ef611 100644 --- a/book/08-customizing-git/sections/hooks.asc +++ b/book/08-customizing-git/sections/hooks.asc @@ -1,131 +1,59 @@ [[_git_hooks]] === Git Hooks +tag::concept[] (((hooks))) -Like many other Version Control Systems, Git has a way to fire off custom scripts when certain important actions occur. -There are two groups of these hooks: client-side and server-side. -Client-side hooks are triggered by operations such as committing and merging, while server-side hooks run on network operations such as receiving pushed commits. -You can use these hooks for all sorts of reasons. +Like a smart prototyping tool that runs scripts when you click a button, Git has a way to fire off custom scripts when important actions occur. These are called **Hooks**. -==== Installing a Hook - -The hooks are all stored in the `hooks` subdirectory of the Git directory. -In most projects, that's `.git/hooks`. -When you initialize a new repository with `git init`, Git populates the hooks directory with a bunch of example scripts, many of which are useful by themselves; but they also document the input values of each script. -All the examples are written as shell scripts, with some Perl thrown in, but any properly named executable scripts will work fine – you can write them in Ruby or Python or whatever language you are familiar with. -If you want to use the bundled hook scripts, you'll have to rename them; their file names all end with `.sample`. - -To enable a hook script, put a file in the `hooks` subdirectory of your `.git` directory that is named appropriately (without any extension) and is executable. -From that point forward, it should be called. -We'll cover most of the major hook filenames here. - -==== Client-Side Hooks - -There are a lot of client-side hooks. -This section splits them into committing-workflow hooks, email-workflow scripts, and everything else. - -[NOTE] -==== -It's important to note that client-side hooks are *not* copied when you clone a repository. -If your intent with these scripts is to enforce a policy, you'll probably want to do that on the server side; see the example in <<ch08-customizing-git#_an_example_git_enforced_policy>>. -==== - -===== Committing-Workflow Hooks - -The first four hooks have to do with the committing process. - -The `pre-commit` hook is run first, before you even type in a commit message. -It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code. -Exiting non-zero from this hook aborts the commit, although you can bypass it with `git commit --no-verify`. -You can do things like check for code style (run `lint` or something equivalent), check for trailing whitespace (the default hook does exactly this), or check for appropriate documentation on new methods. - -The `prepare-commit-msg` hook is run before the commit message editor is fired up but after the default message is created. -It lets you edit the default message before the commit author sees it. -This hook takes a few parameters: the path to the file that holds the commit message so far, the type of commit, and the commit SHA-1 if this is an amended commit. -This hook generally isn't useful for normal commits; rather, it's good for commits where the default message is auto-generated, such as templated commit messages, merge commits, squashed commits, and amended commits. -You may use it in conjunction with a commit template to programmatically insert information. - -The `commit-msg` hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer. -If this script exits non-zero, Git aborts the commit process, so you can use it to validate your project state or commit message before allowing a commit to go through. -In the last section of this chapter, we'll demonstrate using this hook to check that your commit message is conformant to a required pattern. +There are two groups of hooks: +1. **Client-side:** Run on Nora's local computer (e.g., when she runs `git commit`). +2. **Server-side:** Run on the shared team server (e.g., when anyone pushes to GitHub). -After the entire commit process is completed, the `post-commit` hook runs. -It doesn't take any parameters, but you can easily get the last commit by running `git log -1 HEAD`. -Generally, this script is used for notification or something similar. - -[[_email_hooks]] -===== Email Workflow Hooks - -You can set up three client-side hooks for an email-based workflow. -They're all invoked by the `git am` command, so if you aren't using that command in your workflow, you can safely skip to the next section. -If you're taking patches over email prepared by `git format-patch`, then some of these may be helpful to you. - -The first hook that is run is `applypatch-msg`. -It takes a single argument: the name of the temporary file that contains the proposed commit message. -Git aborts the patch if this script exits non-zero. -You can use this to make sure a commit message is properly formatted, or to normalize the message by having the script edit it in place. - -The next hook to run when applying patches via `git am` is `pre-applypatch`. -Somewhat confusingly, it is run _after_ the patch is applied but before a commit is made, so you can use it to inspect the snapshot before making the commit. -You can run tests or otherwise inspect the working tree with this script. -If something is missing or the tests don't pass, exiting non-zero aborts the `git am` script without committing the patch. - -The last hook to run during a `git am` operation is `post-applypatch`, which runs after the commit is made. -You can use it to notify a group or the author of the patch you pulled in that you've done so. -You can't stop the patching process with this script. - -[[_other_client_hooks]] -===== Other Client Hooks - -The `pre-rebase` hook runs before you rebase anything and can halt the process by exiting non-zero. -You can use this hook to disallow rebasing any commits that have already been pushed. -The example `pre-rebase` hook that Git installs does this, although it makes some assumptions that may not match with your workflow. - -The `post-rewrite` hook is run by commands that replace commits, such as `git commit --amend` and `git rebase` (though not by `git filter-branch`). -Its single argument is which command triggered the rewrite, and it receives a list of rewrites on `stdin`. -This hook has many of the same uses as the `post-checkout` and `post-merge` hooks. - -After you run a successful `git checkout`, the `post-checkout` hook runs; you can use it to set up your working directory properly for your project environment. -This may mean moving in large binary files that you don't want source controlled, auto-generating documentation, or something along those lines. - -The `post-merge` hook runs after a successful `merge` command. -You can use it to restore data in the working tree that Git can't track, such as permissions data. -This hook can likewise validate the presence of files external to Git control that you may want copied in when the working tree changes. +==== Installing a Hook +tag::procedure[] -The `pre-push` hook runs during `git push`, after the remote refs have been updated but before any objects have been transferred. -It receives the name and location of the remote as parameters, and a list of to-be-updated refs through `stdin`. -You can use it to validate a set of ref updates before a push occurs (a non-zero exit code will abort the push). +Hooks are stored in the `.git/hooks` directory of your project. Git populates this folder with several sample scripts (ending in `.sample`). To enable one, Nora just needs to rename it and make it executable. -Git occasionally does garbage collection as part of its normal operation, by invoking `git gc --auto`. -The `pre-auto-gc` hook is invoked just before the garbage collection takes place, and can be used to notify you that this is happening, or to abort the collection if now isn't a good time. +[source,bash] +---- +$ mv .git/hooks/pre-commit.sample .git/hooks/pre-commit +$ chmod +x .git/hooks/pre-commit +---- -==== Server-Side Hooks +==== Client-Side Design-Ops +tag::procedure[] -In addition to the client-side hooks, you can use a couple of important server-side hooks as a system administrator to enforce nearly any kind of policy for your project. -These scripts run before and after pushes to the server. -The pre hooks can exit non-zero at any time to reject the push as well as print an error message back to the client; you can set up a push policy that's as complex as you wish. +Nora uses client-side hooks to "outsource" her manual checks. -===== `pre-receive` +##### Pre-Commit: Formatting Check +The `pre-commit` hook runs before Nora even types her message. She uses it to run a script that checks her `design-tokens.json` for syntax errors. If the script finds a mistake, Git will stop the commit and Nora can fix it immediately. -The first script to run when handling a push from a client is `pre-receive`. -It takes a list of references that are being pushed from stdin; if it exits non-zero, none of them are accepted. -You can use this hook to do things like make sure none of the updated references are non-fast-forwards, or to do access control for all the refs and files they're modifying with the push. +##### Commit-Msg: Convention Enforcement +(((git commands, commit-msg))) +To make sure Sam and Priya always use the `[Phase: Component]` prefix, Nora writes a small script for the `commit-msg` hook. If a message doesn't start with the correct brackets, the commit is rejected. -===== `update` +[source,bash] +---- +#!/bin/bash +# .git/hooks/commit-msg script +msg=$(cat "$1") +if [[ ! $msg =~ ^\[.*:.*\] ]]; then + echo "ERROR: Message must follow [Phase: Component] convention." + exit 1 +fi +---- -The `update` script is very similar to the `pre-receive` script, except that it's run once for each branch the pusher is trying to update. -If the pusher is trying to push to multiple branches, `pre-receive` runs only once, whereas `update` runs once per branch they're pushing to. -Instead of reading from stdin, this script takes three arguments: the name of the reference (branch), the SHA-1 that reference pointed to before the push, and the SHA-1 the user is trying to push. -If the `update` script exits non-zero, only that reference is rejected; other references can still be updated. +##### Post-Commit: Instant Feedback +The `post-commit` hook runs after the checkpoint is successfully created. Nora uses this to trigger a local script that generates a low-res preview of any new PNGs she just committed, saving her from doing it manually. -===== `post-receive` +==== Server-Side Policy +tag::concept[] -The `post-receive` hook runs after the entire process is completed and can be used to update other services or notify users. -It takes the same stdin data as the `pre-receive` hook. -Examples include emailing a list, notifying a continuous integration server, or updating a ticket-tracking system – you can even parse the commit messages to see if any tickets need to be opened, modified, or closed. -This script can't stop the push process, but the client doesn't disconnect until it has completed, so be careful if you try to do anything that may take a long time. +As a team leader, Nora uses **server-side hooks** (like `pre-receive`) to enforce project-wide rules. For example, she can set up a hook on the team's server that rejects any push that doesn't include an updated `CHANGELOG.md` file if a major version tag is being pushed. -[TIP] +[NOTE] ==== -If you're writing a script/hook that others will need to read, prefer the long versions of command-line flags; six months from now you'll thank us. +If Nora is using GitHub, many of these server-side checks are handled more easily through the GitHub UI using **Actions** or **Branch Protection** (which we covered in Chapter 6). However, for private or custom servers, these hooks are essential. ==== + +By using hooks, Nora and the SketchSpark team create a self-correcting workflow that catches errors early and automates the repetitive parts of design management. diff --git a/book/08-customizing-git/sections/policy.asc b/book/08-customizing-git/sections/policy.asc index 852a0c03a..c5844bd1a 100644 --- a/book/08-customizing-git/sections/policy.asc +++ b/book/08-customizing-git/sections/policy.asc @@ -1,443 +1,33 @@ [[_an_example_git_enforced_policy]] === An Example Git-Enforced Policy +tag::concept[] (((policy example))) -In this section, you'll use what you've learned to establish a Git workflow that checks for a custom commit message format, and allows only certain users to modify certain subdirectories in a project. -You'll build client scripts that help the developer know if their push will be rejected and server scripts that actually enforce the policies. +As the SketchSpark organization grows into a large enterprise, Nora may need more than just "suggested" guidelines. She can use server-side hooks to build a custom **Policy Enforcement** system. -The scripts we'll show are written in Ruby; partly because of our intellectual inertia, but also because Ruby is easy to read, even if you can't necessarily write it. -However, any language will work – all the sample hook scripts distributed with Git are in either Perl or Bash, so you can also see plenty of examples of hooks in those languages by looking at the samples. +In this section, we’ll look at how Nora uses a Ruby script on the team’s server to enforce two strict rules: +1. **Strict Commit Messages:** Every checkpoint *must* include a link to a design ticket (e.g., `[ref: 123]`). +2. **Access Control (ACL):** Only members of the "System Admins" team can modify the root `.gitattributes` or `design-tokens.json` files. -==== Server-Side Hook +==== Server-Side Enforcement +tag::procedure[] -All the server-side work will go into the `update` file in your `hooks` directory. -The `update` hook runs once per branch being pushed and takes three arguments: +Nora writes an `update` hook (as discussed in the previous section). This script runs on the server every time Sam or Priya pushes their work. -* The name of the reference being pushed to -* The old revision where that branch was -* The new revision being pushed +##### 1. Checking Message Format +The script uses `git rev-list` to get the SHA-1 of every new commit being pushed. For each one, it grabs the message and checks for the `[ref: \d+]` pattern. If any commit message is missing it, the entire push is rejected. -You also have access to the user doing the pushing if the push is being run over SSH. -If you've allowed everyone to connect with a single user (like "`git`") via public-key authentication, you may have to give that user a shell wrapper that determines which user is connecting based on the public key, and set an environment variable accordingly. -Here we'll assume the connecting user is in the `$USER` environment variable, so your update script begins by gathering all the information you need: - -[source,ruby] ----- -#!/usr/bin/env ruby - -$refname = ARGV[0] -$oldrev = ARGV[1] -$newrev = ARGV[2] -$user = ENV['USER'] - -puts "Enforcing Policies..." -puts "(#{$refname}) (#{$oldrev[0,6]}) (#{$newrev[0,6]})" ----- - -Yes, those are global variables. -Don't judge – it's easier to demonstrate this way. - -[[_enforcing_commit_message_format]] -===== Enforcing a Specific Commit-Message Format - -Your first challenge is to enforce that each commit message adheres to a particular format. -Just to have a target, assume that each message has to include a string that looks like "`ref: 1234`" because you want each commit to link to a work item in your ticketing system. -You must look at each commit being pushed up, see if that string is in the commit message, and, if the string is absent from any of the commits, exit non-zero so the push is rejected. - -You can get a list of the SHA-1 values of all the commits that are being pushed by taking the `$newrev` and `$oldrev` values and passing them to a Git plumbing command called `git rev-list`. -This is basically the `git log` command, but by default it prints out only the SHA-1 values and no other information. -So, to get a list of all the commit SHA-1s introduced between one commit SHA-1 and another, you can run something like this: - -[source,console] ----- -$ git rev-list 538c33..d14fc7 -d14fc7c847ab946ec39590d87783c69b031bdfb7 -9f585da4401b0a3999e84113824d15245c13f0be -234071a1be950e2a8d078e6141f5cd20c1e61ad3 -dfa04c9ef3d5197182f13fb5b9b1fb7717d2222a -17716ec0f1ff5c77eff40b7fe912f9f6cfd0e475 ----- - -You can take that output, loop through each of those commit SHA-1s, grab the message for it, and test that message against a regular expression that looks for a pattern. - -You have to figure out how to get the commit message from each of these commits to test. -To get the raw commit data, you can use another plumbing command called `git cat-file`. -We'll go over all these plumbing commands in detail in <<ch10-git-internals#ch10-git-internals>>; but for now, here's what that command gives you: - -[source,console] ----- -$ git cat-file commit ca82a6 -tree cfda3bf379e4f8dba8717dee55aab78aef7f4daf -parent 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 -author Scott Chacon <schacon@gmail.com> 1205815931 -0700 -committer Scott Chacon <schacon@gmail.com> 1240030591 -0700 - -Change the version number ----- - -A simple way to get the commit message from a commit when you have the SHA-1 value is to go to the first blank line and take everything after that. -You can do so with the `sed` command on Unix systems: - -[source,console] ----- -$ git cat-file commit ca82a6 | sed '1,/^$/d' -Change the version number ----- - -You can use that incantation to grab the commit message from each commit that is trying to be pushed and exit if you see anything that doesn't match. -To exit the script and reject the push, exit non-zero. -The whole method looks like this: - -[source,ruby] ----- -$regex = /\[ref: (\d+)\]/ - -# enforced custom commit message format -def check_message_format - missed_revs = `git rev-list #{$oldrev}..#{$newrev}`.split("\n") - missed_revs.each do |rev| - message = `git cat-file commit #{rev} | sed '1,/^$/d'` - if !$regex.match(message) - puts "[POLICY] Your message is not formatted correctly" - exit 1 - end - end -end -check_message_format ----- - -Putting that in your `update` script will reject updates that contain commits that have messages that don't adhere to your rule. - -===== Enforcing a User-Based ACL System - -Suppose you want to add a mechanism that uses an access control list (ACL) that specifies which users are allowed to push changes to which parts of your projects. -Some people have full access, and others can only push changes to certain subdirectories or specific files. -To enforce this, you'll write those rules to a file named `acl` that lives in your bare Git repository on the server. -You'll have the `update` hook look at those rules, see what files are being introduced for all the commits being pushed, and determine whether the user doing the push has access to update all those files. - -The first thing you'll do is write your ACL. -Here you'll use a format very much like the CVS ACL mechanism: it uses a series of lines, where the first field is `avail` or `unavail`, the next field is a comma-delimited list of the users to which the rule applies, and the last field is the path to which the rule applies (blank meaning open access). -All of these fields are delimited by a pipe (`|`) character. - -In this case, you have a couple of administrators, some documentation writers with access to the `doc` directory, and one developer who only has access to the `lib` and `tests` directories, and your ACL file looks like this: - -[source] ----- -avail|nickh,pjhyett,defunkt,tpw -avail|usinclair,cdickens,ebronte|doc -avail|schacon|lib -avail|schacon|tests ----- - -You begin by reading this data into a structure that you can use. -In this case, to keep the example simple, you'll only enforce the `avail` directives. -Here is a method that gives you an associative array where the key is the user name and the value is an array of paths to which the user has write access: - -[source,ruby] ----- -def get_acl_access_data(acl_file) - # read in ACL data - acl_file = File.read(acl_file).split("\n").reject { |line| line == '' } - access = {} - acl_file.each do |line| - avail, users, path = line.split('|') - next unless avail == 'avail' - users.split(',').each do |user| - access[user] ||= [] - access[user] << path - end - end - access -end ----- - -On the ACL file you looked at earlier, this `get_acl_access_data` method returns a data structure that looks like this: - -[source,ruby] ----- -{"defunkt"=>[nil], - "tpw"=>[nil], - "nickh"=>[nil], - "pjhyett"=>[nil], - "schacon"=>["lib", "tests"], - "cdickens"=>["doc"], - "usinclair"=>["doc"], - "ebronte"=>["doc"]} ----- - -Now that you have the permissions sorted out, you need to determine what paths the commits being pushed have modified, so you can make sure the user who's pushing has access to all of them. - -You can pretty easily see what files have been modified in a single commit with the `--name-only` option to the `git log` command (mentioned briefly in <<ch02-git-basics-chapter#ch02-git-basics-chapter>>): - -[source,console] ----- -$ git log -1 --name-only --pretty=format:'' 9f585d - -README -lib/test.rb ----- - -If you use the ACL structure returned from the `get_acl_access_data` method and check it against the listed files in each of the commits, you can determine whether the user has access to push all of their commits: - -[source,ruby] ----- -# only allows certain users to modify certain subdirectories in a project -def check_directory_perms - access = get_acl_access_data('acl') - - # see if anyone is trying to push something they can't - new_commits = `git rev-list #{$oldrev}..#{$newrev}`.split("\n") - new_commits.each do |rev| - files_modified = `git log -1 --name-only --pretty=format:'' #{rev}`.split("\n") - files_modified.each do |path| - next if path.size == 0 - has_file_access = false - access[$user].each do |access_path| - if !access_path # user has access to everything - || (path.start_with? access_path) # access to this path - has_file_access = true - end - end - if !has_file_access - puts "[POLICY] You do not have access to push to #{path}" - exit 1 - end - end - end -end - -check_directory_perms ----- - -You get a list of new commits being pushed to your server with `git rev-list`. -Then, for each of those commits, you find which files are modified and make sure the user who's pushing has access to all the paths being modified. - -Now your users can't push any commits with badly formed messages or with modified files outside of their designated paths. - -===== Testing It Out - -If you run `chmod u+x .git/hooks/update`, which is the file into which you should have put all this code, and then try to push a commit with a non-compliant message, you get something like this: - -[source,console] ----- -$ git push -f origin master -Counting objects: 5, done. -Compressing objects: 100% (3/3), done. -Writing objects: 100% (3/3), 323 bytes, done. -Total 3 (delta 1), reused 0 (delta 0) -Unpacking objects: 100% (3/3), done. -Enforcing Policies... -(refs/heads/master) (8338c5) (c5b616) -[POLICY] Your message is not formatted correctly -error: hooks/update exited with error code 1 -error: hook declined to update refs/heads/master -To git@gitserver:project.git - ! [remote rejected] master -> master (hook declined) -error: failed to push some refs to 'git@gitserver:project.git' ----- - -There are a couple of interesting things here. -First, you see this where the hook starts running. - -[source,console] ----- -Enforcing Policies... -(refs/heads/master) (fb8c72) (c56860) ----- - -Remember that you printed that out at the very beginning of your update script. -Anything your script echoes to `stdout` will be transferred to the client. - -The next thing you'll notice is the error message. - -[source,console] ----- -[POLICY] Your message is not formatted correctly -error: hooks/update exited with error code 1 -error: hook declined to update refs/heads/master ----- - -The first line was printed out by you, the other two were Git telling you that the update script exited non-zero and that is what is declining your push. -Lastly, you have this: - -[source,console] ----- -To git@gitserver:project.git - ! [remote rejected] master -> master (hook declined) -error: failed to push some refs to 'git@gitserver:project.git' ----- - -You'll see a remote rejected message for each reference that your hook declined, and it tells you that it was declined specifically because of a hook failure. - -Furthermore, if someone tries to edit a file they don't have access to and push a commit containing it, they will see something similar. -For instance, if a documentation author tries to push a commit modifying something in the `lib` directory, they see: - -[source,console] ----- -[POLICY] You do not have access to push to lib/test.rb ----- - -From now on, as long as that `update` script is there and executable, your repository will never have a commit message without your pattern in it, and your users will be sandboxed. - -==== Client-Side Hooks - -The downside to this approach is the whining that will inevitably result when your users' commit pushes are rejected. -Having their carefully crafted work rejected at the last minute can be extremely frustrating and confusing; and furthermore, they will have to edit their history to correct it, which isn't always for the faint of heart. - -The answer to this dilemma is to provide some client-side hooks that users can run to notify them when they're doing something that the server is likely to reject. -That way, they can correct any problems before committing and before those issues become more difficult to fix. -Because hooks aren't transferred with a clone of a project, you must distribute these scripts some other way and then have your users copy them to their `.git/hooks` directory and make them executable. -You can distribute these hooks within the project or in a separate project, but Git won't set them up automatically. - -To begin, you should check your commit message just before each commit is recorded, so you know the server won't reject your changes due to badly formatted commit messages. -To do this, you can add the `commit-msg` hook. -If you have it read the message from the file passed as the first argument and compare that to the pattern, you can force Git to abort the commit if there is no match: - -[source,ruby] ----- -#!/usr/bin/env ruby -message_file = ARGV[0] -message = File.read(message_file) - -$regex = /\[ref: (\d+)\]/ - -if !$regex.match(message) - puts "[POLICY] Your message is not formatted correctly" - exit 1 -end ----- - -If that script is in place (in `.git/hooks/commit-msg`) and executable, and you commit with a message that isn't properly formatted, you see this: - -[source,console] ----- -$ git commit -am 'Test' -[POLICY] Your message is not formatted correctly ----- - -No commit was completed in that instance. -However, if your message contains the proper pattern, Git allows you to commit: - -[source,console] ----- -$ git commit -am 'Test [ref: 132]' -[master e05c914] Test [ref: 132] - 1 file changed, 1 insertions(+), 0 deletions(-) ----- - -Next, you want to make sure you aren't modifying files that are outside your ACL scope. -If your project's `.git` directory contains a copy of the ACL file you used previously, then the following `pre-commit` script will enforce those constraints for you: - -[source,ruby] ----- -#!/usr/bin/env ruby - -$user = ENV['USER'] - -# [ insert acl_access_data method from above ] - -# only allows certain users to modify certain subdirectories in a project -def check_directory_perms - access = get_acl_access_data('.git/acl') - - files_modified = `git diff-index --cached --name-only HEAD`.split("\n") - files_modified.each do |path| - next if path.size == 0 - has_file_access = false - access[$user].each do |access_path| - if !access_path || (path.index(access_path) == 0) - has_file_access = true - end - if !has_file_access - puts "[POLICY] You do not have access to push to #{path}" - exit 1 - end - end -end - -check_directory_perms ----- - -This is roughly the same script as the server-side part, but with two important differences. -First, the ACL file is in a different place, because this script runs from your working directory, not from your `.git` directory. -You have to change the path to the ACL file from this: - -[source,ruby] ----- -access = get_acl_access_data('acl') ----- - -to this: - -[source,ruby] ----- -access = get_acl_access_data('.git/acl') ----- - -The other important difference is the way you get a listing of the files that have been changed. -Because the server-side method looks at the log of commits, and, at this point, the commit hasn't been recorded yet, you must get your file listing from the staging area instead. -Instead of: - -[source,ruby] ----- -files_modified = `git log -1 --name-only --pretty=format:'' #{ref}` ----- - -you have to use: - -[source,ruby] ----- -files_modified = `git diff-index --cached --name-only HEAD` ----- - -But those are the only two differences – otherwise, the script works the same way. -One caveat is that it expects you to be running locally as the same user you push as to the remote machine. -If that is different, you must set the `$user` variable manually. - -One other thing we can do here is make sure the user doesn't push non-fast-forwarded references. -To get a reference that isn't a fast-forward, you either have to rebase past a commit you've already pushed up or try pushing a different local branch up to the same remote branch. - -Presumably, the server is already configured with `receive.denyDeletes` and `receive.denyNonFastForwards` to enforce this policy, so the only accidental thing you can try to catch is rebasing commits that have already been pushed. - -Here is an example pre-rebase script that checks for that. -It gets a list of all the commits you're about to rewrite and checks whether they exist in any of your remote references. -If it sees one that is reachable from one of your remote references, it aborts the rebase. - -[source,ruby] ----- -#!/usr/bin/env ruby - -base_branch = ARGV[0] -if ARGV[1] - topic_branch = ARGV[1] -else - topic_branch = "HEAD" -end - -target_shas = `git rev-list #{base_branch}..#{topic_branch}`.split("\n") -remote_refs = `git branch -r`.split("\n").map { |r| r.strip } - -target_shas.each do |sha| - remote_refs.each do |remote_ref| - shas_pushed = `git rev-list ^#{sha}^@ refs/remotes/#{remote_ref}` - if shas_pushed.split("\n").include?(sha) - puts "[POLICY] Commit #{sha} has already been pushed to #{remote_ref}" - exit 1 - end - end -end ----- - -This script uses a syntax that wasn't covered in <<ch07-git-tools#_revision_selection>>. -You get a list of commits that have already been pushed up by running this: - -[source,ruby] +##### 2. User-Based Access (ACL) +Nora maintains a small text file on the server (an Access Control List) that looks like this: +[source,text] ---- -`git rev-list ^#{sha}^@ refs/remotes/#{remote_ref}` +avail|nora-ux +avail|sam-ui|screens/ +avail|priya-illustrator|illustrations/ ---- +The script checks who is pushing and what files they've changed. If Sam tries to modify a file in the `illustrations/` directory, the hook will decline the push with a helpful error message: `[POLICY] You do not have access to push to illustrations/hero.png`. -The `SHA^@` syntax resolves to all the parents of that commit. -You're looking for any commit that is reachable from the last commit on the remote and that isn't reachable from any parent of any of the SHA-1s you're trying to push up – meaning it's a fast-forward. +==== The Power of Choice +tag::overview[] -The main drawback to this approach is that it can be very slow and is often unnecessary – if you don't try to force the push with `-f`, the server will warn you and not accept the push. -However, it's an interesting exercise and can in theory help you avoid a rebase that you might later have to go back and fix. +While this level of control might feel like "overkill" for a small startup, it is invaluable for large design organizations that must maintain high standards across thousands of assets. By combining client-side configuration with server-side enforcement, Nora ensures that the SketchSpark "source of truth" remains clean, compliant, and perfectly organized. diff --git a/book/09-git-and-other-scms/sections/client-svn.asc b/book/09-git-and-other-scms/sections/client-svn.asc index de330a1b2..0ebefedb0 100644 --- a/book/09-git-and-other-scms/sections/client-svn.asc +++ b/book/09-git-and-other-scms/sections/client-svn.asc @@ -1,490 +1,54 @@ [[_git_svn]] -==== Git and Subversion +=== Git and Subversion +tag::concept[] (((Subversion)))(((Interoperation with other VCSs, Subversion))) -A large fraction of open source development projects and a good number of corporate projects use Subversion to manage their source code. -It's been around for more than a decade, and for most of that time was the _de facto_ VCS choice for open-source projects. -It's also very similar in many ways to CVS, which was the big boy of the source-control world before that. +Before Nora founded SketchSpark, she worked at a large design agency that used **Subversion (SVN)** to manage all its research and assets. Subversion was the industry standard for over a decade, and many legacy design projects are still locked inside it. -(((git commands, svn)))(((git-svn))) -One of Git's great features is a bidirectional bridge to Subversion called `git svn`. -This tool allows you to use Git as a valid client to a Subversion server, so you can use all the local features of Git and then push to a Subversion server as if you were using Subversion locally. -This means you can do local branching and merging, use the staging area, use rebasing and cherry-picking, and so on, while your collaborators continue to work in their dark and ancient ways. -It's a good way to sneak Git into the corporate environment and help your fellow developers become more efficient while you lobby to get the infrastructure changed to support Git fully. -The Subversion bridge is the gateway drug to the DVCS world. - -===== `git svn` - -The base command in Git for all the Subversion bridging commands is `git svn`. -It takes quite a few commands, so we'll show the most common while going through a few simple workflows. - -It's important to note that when you're using `git svn`, you're interacting with Subversion, which is a system that works very differently from Git. -Although you *can* do local branching and merging, it's generally best to keep your history as linear as possible by rebasing your work, and avoiding doing things like simultaneously interacting with a Git remote repository. - -Don't rewrite your history and try to push again, and don't push to a parallel Git repository to collaborate with fellow Git developers at the same time. -Subversion can have only a single linear history, and confusing it is very easy. -If you're working with a team, and some are using SVN and others are using Git, make sure everyone is using the SVN server to collaborate – doing so will make your life easier. - -===== Setting Up - -To demonstrate this functionality, you need a typical SVN repository that you have write access to. -If you want to copy these examples, you'll have to make a writeable copy of an SVN test repository. -In order to do that easily, you can use a tool called `svnsync` that comes with Subversion. - -To follow along, you first need to create a new local Subversion repository: - -[source,console] ----- -$ mkdir /tmp/test-svn -$ svnadmin create /tmp/test-svn ----- - -Then, enable all users to change revprops – the easy way is to add a `pre-revprop-change` script that always exits 0: - -[source,console] ----- -$ cat /tmp/test-svn/hooks/pre-revprop-change -#!/bin/sh -exit 0; -$ chmod +x /tmp/test-svn/hooks/pre-revprop-change ----- - -You can now sync this project to your local machine by calling `svnsync init` with the to and from repositories. - -[source,console] ----- -$ svnsync init file:///tmp/test-svn \ - http://your-svn-server.example.org/svn/ ----- - -This sets up the properties to run the sync. -You can then clone the code by running: - -[source,console] ----- -$ svnsync sync file:///tmp/test-svn -Committed revision 1. -Copied properties for revision 1. -Transmitting file data .............................[...] -Committed revision 2. -Copied properties for revision 2. -[…] ----- - -Although this operation may take only a few minutes, if you try to copy the original repository to another remote repository instead of a local one, the process will take nearly an hour, even though there are fewer than 100 commits. -Subversion has to clone one revision at a time and then push it back into another repository – it's ridiculously inefficient, but it's the only easy way to do this. - -===== Getting Started - -Now that you have a Subversion repository to which you have write access, you can go through a typical workflow. -You'll start with the `git svn clone` command, which imports an entire Subversion repository into a local Git repository. -Remember that if you're importing from a real hosted Subversion repository, you should replace the `\file:///tmp/test-svn` here with the URL of your Subversion repository: - -[source,console] ----- -$ git svn clone file:///tmp/test-svn -T trunk -b branches -t tags -Initialized empty Git repository in /private/tmp/progit/test-svn/.git/ -r1 = dcbfb5891860124cc2e8cc616cded42624897125 (refs/remotes/origin/trunk) - A m4/acx_pthread.m4 - A m4/stl_hash.m4 - A java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java - A java/src/test/java/com/google/protobuf/WireFormatTest.java -… -r75 = 556a3e1e7ad1fde0a32823fc7e4d046bcfd86dae (refs/remotes/origin/trunk) -Found possible branch point: file:///tmp/test-svn/trunk => file:///tmp/test-svn/branches/my-calc-branch, 75 -Found branch parent: (refs/remotes/origin/my-calc-branch) 556a3e1e7ad1fde0a32823fc7e4d046bcfd86dae -Following parent with do_switch -Successfully followed parent -r76 = 0fb585761df569eaecd8146c71e58d70147460a2 (refs/remotes/origin/my-calc-branch) -Checked out HEAD: - file:///tmp/test-svn/trunk r75 ----- - -This runs the equivalent of two commands – `git svn init` followed by `git svn fetch` – on the URL you provide. -This can take a while. -If, for example, the test project has only about 75 commits and the codebase isn't that big, Git nevertheless must check out each version, one at a time, and commit it individually. -For a project with hundreds or thousands of commits, this can literally take hours or even days to finish. - -The `-T trunk -b branches -t tags` part tells Git that this Subversion repository follows the basic branching and tagging conventions. -If you name your trunk, branches, or tags differently, you can change these options. -Because this is so common, you can replace this entire part with `-s`, which means standard layout and implies all those options. -The following command is equivalent: - -[source,console] ----- -$ git svn clone file:///tmp/test-svn -s ----- +One of Git's most powerful features is a bidirectional bridge to Subversion called **`git svn`**. This tool allowed Nora to use Git locally on her machine—enjoying all the speed, branching, and stashing features she loves—while still "talking" to her agency's old SVN server. -At this point, you should have a valid Git repository that has imported your branches and tags: - -[source,console] ----- -$ git branch -a -* master - remotes/origin/my-calc-branch - remotes/origin/tags/2.0.2 - remotes/origin/tags/release-2.0.1 - remotes/origin/tags/release-2.0.2 - remotes/origin/tags/release-2.0.2rc1 - remotes/origin/trunk ----- - -Note how this tool manages Subversion tags as remote refs. -(((git commands, show-ref))) -Let's take a closer look with the Git plumbing command `show-ref`: - -[source,console] ----- -$ git show-ref -556a3e1e7ad1fde0a32823fc7e4d046bcfd86dae refs/heads/master -0fb585761df569eaecd8146c71e58d70147460a2 refs/remotes/origin/my-calc-branch -bfd2d79303166789fc73af4046651a4b35c12f0b refs/remotes/origin/tags/2.0.2 -285c2b2e36e467dd4d91c8e3c0c0e1750b3fe8ca refs/remotes/origin/tags/release-2.0.1 -cbda99cb45d9abcb9793db1d4f70ae562a969f1e refs/remotes/origin/tags/release-2.0.2 -a9f074aa89e826d6f9d30808ce5ae3ffe711feda refs/remotes/origin/tags/release-2.0.2rc1 -556a3e1e7ad1fde0a32823fc7e4d046bcfd86dae refs/remotes/origin/trunk ----- - -Git doesn't do this when it clones from a Git server; here's what a repository with tags looks like after a fresh clone: - -[source,console] ----- -$ git show-ref -c3dcbe8488c6240392e8a5d7553bbffcb0f94ef0 refs/remotes/origin/master -32ef1d1c7cc8c603ab78416262cc421b80a8c2df refs/remotes/origin/branch-1 -75f703a3580a9b81ead89fe1138e6da858c5ba18 refs/remotes/origin/branch-2 -23f8588dde934e8f33c263c6d8359b2ae095f863 refs/tags/v0.1.0 -7064938bd5e7ef47bfd79a685a62c1e2649e2ce7 refs/tags/v0.2.0 -6dcb09b5b57875f334f61aebed695e2e4193db5e refs/tags/v1.0.0 ----- - -Git fetches the tags directly into `refs/tags`, rather than treating them as remote branches. - -===== Committing Back to Subversion - -Now that you have a working directory, you can do some work on the project and push your commits back upstream, using Git effectively as an SVN client. -If you edit one of the files and commit it, you have a commit that exists in Git locally that doesn't exist on the Subversion server: - -[source,console] ----- -$ git commit -am 'Adding git-svn instructions to the README' -[master 4af61fd] Adding git-svn instructions to the README - 1 file changed, 5 insertions(+) ----- - -Next, you need to push your change upstream. -Notice how this changes the way you work with Subversion – you can do several commits offline and then push them all at once to the Subversion server. -To push to a Subversion server, you run the `git svn dcommit` command: - -[source,console] ----- -$ git svn dcommit -Committing to file:///tmp/test-svn/trunk ... - M README.txt -Committed r77 - M README.txt -r77 = 95e0222ba6399739834380eb10afcd73e0670bc5 (refs/remotes/origin/trunk) -No changes between 4af61fd05045e07598c553167e0f31c84fd6ffe1 and refs/remotes/origin/trunk -Resetting to the latest refs/remotes/origin/trunk ----- - -This takes all the commits you've made on top of the Subversion server code, does a Subversion commit for each, and then rewrites your local Git commit to include a unique identifier. -This is important because it means that all the SHA-1 checksums for your commits change. -Partly for this reason, working with Git-based remote versions of your projects concurrently with a Subversion server isn't a good idea. -If you look at the last commit, you can see the new `git-svn-id` that was added: - -[source,console] ----- -$ git log -1 -commit 95e0222ba6399739834380eb10afcd73e0670bc5 -Author: ben <ben@0b684db3-b064-4277-89d1-21af03df0a68> -Date: Thu Jul 24 03:08:36 2014 +0000 - - Adding git-svn instructions to the README - - git-svn-id: file:///tmp/test-svn/trunk@77 0b684db3-b064-4277-89d1-21af03df0a68 ----- - -Notice that the SHA-1 checksum that originally started with `4af61fd` when you committed now begins with `95e0222`. -If you want to push to both a Git server and a Subversion server, you have to push (`dcommit`) to the Subversion server first, because that action changes your commit data. - -===== Pulling in New Changes - -If you're working with other developers, then at some point one of you will push, and then the other one will try to push a change that conflicts. -That change will be rejected until you merge in their work. -In `git svn`, it looks like this: - -[source,console] ----- -$ git svn dcommit -Committing to file:///tmp/test-svn/trunk ... +==== Using Git as an SVN Client +tag::procedure[] -ERROR from SVN: -Transaction is out of date: File '/trunk/README.txt' is out of date -W: d5837c4b461b7c0e018b49d12398769d2bfc240a and refs/remotes/origin/trunk differ, using rebase: -:100644 100644 f414c433af0fd6734428cf9d2a9fd8ba00ada145 c80b6127dd04f5fcda218730ddf3a2da4eb39138 M README.txt -Current branch master is up to date. -ERROR: Not all changes have been committed into SVN, however the committed -ones (if any) seem to be successfully integrated into the working tree. -Please see the above messages for details. ----- +(((git commands, svn)))(((git-svn))) +Nora used `git svn` as her "gateway drug" to the world of modern version control. It allowed her to work in her own way while her teammates continued to use their "dark and ancient" SVN workflows. -To resolve this situation, you can run `git svn rebase`, which pulls down any changes on the server that you don't have yet and rebases any work you have on top of what is on the server: +##### 1. Cloning the Legacy Repo +To bring her old research into Git, Nora didn't just copy the files. She used `git svn clone` to pull the entire history of the project, including every branch and tag: -[source,console] +[source,bash] ---- -$ git svn rebase -Committing to file:///tmp/test-svn/trunk ... - -ERROR from SVN: -Transaction is out of date: File '/trunk/README.txt' is out of date -W: eaa029d99f87c5c822c5c29039d19111ff32ef46 and refs/remotes/origin/trunk differ, using rebase: -:100644 100644 65536c6e30d263495c17d781962cfff12422693a b34372b25ccf4945fe5658fa381b075045e7702a M README.txt -First, rewinding head to replay your work on top of it... -Applying: update foo -Using index info to reconstruct a base tree... -M README.txt -Falling back to patching base and 3-way merge... -Auto-merging README.txt -ERROR: Not all changes have been committed into SVN, however the committed -ones (if any) seem to be successfully integrated into the working tree. -Please see the above messages for details. +$ git svn clone https://agency-server.com/svn/project-x -s ---- -Now, all your work is on top of what is on the Subversion server, so you can successfully `dcommit`: - -[source,console] ----- -$ git svn dcommit -Committing to file:///tmp/test-svn/trunk ... - M README.txt -Committed r85 - M README.txt -r85 = 9c29704cc0bbbed7bd58160cfb66cb9191835cd8 (refs/remotes/origin/trunk) -No changes between 5762f56732a958d6cfda681b661d2a239cc53ef5 and refs/remotes/origin/trunk -Resetting to the latest refs/remotes/origin/trunk ----- +The `-s` flag tells Git that the SVN repo follows the "standard layout" (with folders named `trunk`, `branches`, and `tags`). Git then goes through every SVN revision and creates a corresponding Git checkpoint. -Note that unlike Git, which requires you to merge upstream work you don't yet have locally before you can push, `git svn` makes you do that only if the changes conflict (much like how Subversion works). -If someone else pushes a change to one file and then you push a change to another file, your `dcommit` will work fine: +##### 2. Committing Back to SVN +When Nora finished a new persona document in Git, she wanted to share it with her agency teammates who were still using SVN. She ran: -[source,console] +[source,bash] ---- $ git svn dcommit -Committing to file:///tmp/test-svn/trunk ... - M configure.ac -Committed r87 - M autogen.sh -r86 = d8450bab8a77228a644b7dc0e95977ffc61adff7 (refs/remotes/origin/trunk) - M configure.ac -r87 = f3653ea40cb4e26b6281cec102e35dcba1fe17c4 (refs/remotes/origin/trunk) -W: a0253d06732169107aa020390d9fefd2b1d92806 and refs/remotes/origin/trunk differ, using rebase: -:100755 100755 efa5a59965fbbb5b2b0a12890f1b351bb5493c18 e757b59a9439312d80d5d43bb65d4a7d0389ed6d M autogen.sh -First, rewinding head to replay your work on top of it... ---- -This is important to remember, because the outcome is a project state that didn't exist on either of your computers when you pushed. -If the changes are incompatible but don't conflict, you may get issues that are difficult to diagnose. -This is different than using a Git server – in Git, you can fully test the state on your client system before publishing it, whereas in SVN, you can't ever be certain that the states immediately before commit and after commit are identical. +This command takes Nora's local Git commits and "pushes" them into the SVN server as new revisions. To her teammates, it looks like she never left Subversion. -You should also run this command to pull in changes from the Subversion server, even if you're not ready to commit yourself. -You can run `git svn fetch` to grab the new data, but `git svn rebase` does the fetch and then updates your local commits. +##### 3. Pulling Updates +To see what her teammates had updated on the SVN server, Nora used: -[source,console] +[source,bash] ---- $ git svn rebase - M autogen.sh -r88 = c9c5f83c64bd755368784b444bc7a0216cc1e17b (refs/remotes/origin/trunk) -First, rewinding head to replay your work on top of it... -Fast-forwarded master to refs/remotes/origin/trunk. ----- - -Running `git svn rebase` every once in a while makes sure your code is always up to date. -You need to be sure your working directory is clean when you run this, though. -If you have local changes, you must either stash your work or temporarily commit it before running `git svn rebase` – otherwise, the command will stop if it sees that the rebase will result in a merge conflict. - -===== Git Branching Issues - -When you've become comfortable with a Git workflow, you'll likely create topic branches, do work on them, and then merge them in. -If you're pushing to a Subversion server via `git svn`, you may want to rebase your work onto a single branch each time instead of merging branches together. -The reason to prefer rebasing is that Subversion has a linear history and doesn't deal with merges like Git does, so `git svn` follows only the first parent when converting the snapshots into Subversion commits. - -Suppose your history looks like the following: you created an `experiment` branch, did two commits, and then merged them back into `master`. -When you `dcommit`, you see output like this: - -[source,console] ----- -$ git svn dcommit -Committing to file:///tmp/test-svn/trunk ... - M CHANGES.txt -Committed r89 - M CHANGES.txt -r89 = 89d492c884ea7c834353563d5d913c6adf933981 (refs/remotes/origin/trunk) - M COPYING.txt - M INSTALL.txt -Committed r90 - M INSTALL.txt - M COPYING.txt -r90 = cb522197870e61467473391799148f6721bcf9a0 (refs/remotes/origin/trunk) -No changes between 71af502c214ba13123992338569f4669877f55fd and refs/remotes/origin/trunk -Resetting to the latest refs/remotes/origin/trunk ---- -Running `dcommit` on a branch with merged history works fine, except that when you look at your Git project history, it hasn't rewritten either of the commits you made on the `experiment` branch – instead, all those changes appear in the SVN version of the single merge commit. - -When someone else clones that work, all they see is the merge commit with all the work squashed into it, as though you ran `git merge --squash`; they don't see the commit data about where it came from or when it was committed. - -===== Subversion Branching - -Branching in Subversion isn't the same as branching in Git; if you can avoid using it much, that's probably best. -However, you can create and commit to branches in Subversion using `git svn`. - -===== Creating a New SVN Branch - -To create a new branch in Subversion, you run `git svn branch [new-branch]`: - -[source,console] ----- -$ git svn branch opera -Copying file:///tmp/test-svn/trunk at r90 to file:///tmp/test-svn/branches/opera... -Found possible branch point: file:///tmp/test-svn/trunk => file:///tmp/test-svn/branches/opera, 90 -Found branch parent: (refs/remotes/origin/opera) cb522197870e61467473391799148f6721bcf9a0 -Following parent with do_switch -Successfully followed parent -r91 = f1b64a3855d3c8dd84ee0ef10fa89d27f1584302 (refs/remotes/origin/opera) ----- - -This does the equivalent of the `svn copy trunk branches/opera` command in Subversion and operates on the Subversion server. -It's important to note that it doesn't check you out into that branch; if you commit at this point, that commit will go to `trunk` on the server, not `opera`. - -===== Switching Active Branches - -Git figures out what branch your dcommits go to by looking for the tip of any of your Subversion branches in your history – you should have only one, and it should be the last one with a `git-svn-id` in your current branch history. - -If you want to work on more than one branch simultaneously, you can set up local branches to `dcommit` to specific Subversion branches by starting them at the imported Subversion commit for that branch. -If you want an `opera` branch that you can work on separately, you can run: - -[source,console] ----- -$ git branch opera remotes/origin/opera ----- - -Now, if you want to merge your `opera` branch into `trunk` (your `master` branch), you can do so with a normal `git merge`. -But you need to provide a descriptive commit message (via `-m`), or the merge will say "`Merge branch opera`" instead of something useful. - -Remember that although you're using `git merge` to do this operation, and the merge likely will be much easier than it would be in Subversion (because Git will automatically detect the appropriate merge base for you), this isn't a normal Git merge commit. -You have to push this data back to a Subversion server that can't handle a commit that tracks more than one parent; so, after you push it up, it will look like a single commit that squashed in all the work of another branch under a single commit. -After you merge one branch into another, you can't easily go back and continue working on that branch, as you normally can in Git. -The `dcommit` command that you run erases any information that says what branch was merged in, so subsequent merge-base calculations will be wrong – the `dcommit` makes your `git merge` result look like you ran `git merge --squash`. -Unfortunately, there's no good way to avoid this situation – Subversion can't store this information, so you'll always be crippled by its limitations while you're using it as your server. -To avoid issues, you should delete the local branch (in this case, `opera`) after you merge it into trunk. - -===== Subversion Commands - -The `git svn` toolset provides a number of commands to help ease the transition to Git by providing some functionality that's similar to what you had in Subversion. -Here are a few commands that give you what Subversion used to. - -====== SVN Style History - -If you're used to Subversion and want to see your history in SVN output style, you can run `git svn log` to view your commit history in SVN formatting: - -[source,console] ----- -$ git svn log ------------------------------------------------------------------------- -r87 | schacon | 2014-05-02 16:07:37 -0700 (Sat, 02 May 2014) | 2 lines - -autogen change - ------------------------------------------------------------------------- -r86 | schacon | 2014-05-02 16:00:21 -0700 (Sat, 02 May 2014) | 2 lines - -Merge branch 'experiment' - ------------------------------------------------------------------------- -r85 | schacon | 2014-05-02 16:00:09 -0700 (Sat, 02 May 2014) | 2 lines - -updated the changelog ----- - -You should know two important things about `git svn log`. -First, it works offline, unlike the real `svn log` command, which asks the Subversion server for the data. -Second, it only shows you commits that have been committed up to the Subversion server. -Local Git commits that you haven't dcommited don't show up; neither do commits that people have made to the Subversion server in the meantime. -It's more like the last known state of the commits on the Subversion server. - -====== SVN Annotation - -Much as the `git svn log` command simulates the `svn log` command offline, you can get the equivalent of `svn annotate` by running `git svn blame [FILE]`. -The output looks like this: - -[source,console] ----- -$ git svn blame README.txt - 2 temporal Protocol Buffers - Google's data interchange format - 2 temporal Copyright 2008 Google Inc. - 2 temporal http://code.google.com/apis/protocolbuffers/ - 2 temporal -22 temporal C++ Installation - Unix -22 temporal ======================= - 2 temporal -79 schacon Committing in git-svn. -78 schacon - 2 temporal To build and install the C++ Protocol Buffer runtime and the Protocol - 2 temporal Buffer compiler (protoc) execute the following: - 2 temporal ----- - -Again, it doesn't show commits that you did locally in Git or that have been pushed to Subversion in the meantime. - -====== SVN Server Information - -You can also get the same sort of information that `svn info` gives you by running `git svn info`: - -[source,console] ----- -$ git svn info -Path: . -URL: https://schacon-test.googlecode.com/svn/trunk -Repository Root: https://schacon-test.googlecode.com/svn -Repository UUID: 4c93b258-373f-11de-be05-5f7a86268029 -Revision: 87 -Node Kind: directory -Schedule: normal -Last Changed Author: schacon -Last Changed Rev: 87 -Last Changed Date: 2009-05-02 16:07:37 -0700 (Sat, 02 May 2009) ----- - -This is like `blame` and `log` in that it runs offline and is up to date only as of the last time you communicated with the Subversion server. - -====== Ignoring What Subversion Ignores - -If you clone a Subversion repository that has `svn:ignore` properties set anywhere, you'll likely want to set corresponding `.gitignore` files so you don't accidentally commit files that you shouldn't. -`git svn` has two commands to help with this issue. -The first is `git svn create-ignore`, which automatically creates corresponding `.gitignore` files for you so your next commit can include them. - -The second command is `git svn show-ignore`, which prints to stdout the lines you need to put in a `.gitignore` file so you can redirect the output into your project exclude file: - -[source,console] ----- -$ git svn show-ignore > .git/info/exclude ----- - -That way, you don't litter the project with `.gitignore` files. -This is a good option if you're the only Git user on a Subversion team, and your teammates don't want `.gitignore` files in the project. - -===== Git-Svn Summary +This fetches the latest SVN revisions and "replays" Nora's local work on top of them, keeping her history clean and linear (which SVN requires). -The `git svn` tools are useful if you're stuck with a Subversion server, or are otherwise in a development environment that necessitates running a Subversion server. -You should consider it crippled Git, however, or you'll hit issues in translation that may confuse you and your collaborators. -To stay out of trouble, try to follow these guidelines: +==== The "Bridge" Strategy +tag::overview[] -* Keep a linear Git history that doesn't contain merge commits made by `git merge`. - Rebase any work you do outside of your mainline branch back onto it; don't merge it in. -* Don't set up and collaborate on a separate Git server. - Possibly have one to speed up clones for new developers, but don't push anything to it that doesn't have a `git-svn-id` entry. - You may even want to add a `pre-receive` hook that checks each commit message for a `git-svn-id` and rejects pushes that contain commits without it. +The Subversion bridge is a great way to transition a team. Nora used it for two weeks to "prove" that Git worked for her design assets before she finally convinced the agency to shut down the SVN server and move the whole project to GitHub. -If you follow those guidelines, working with a Subversion server can be more bearable. -However, if it's possible to move to a real Git server, doing so can gain your team a lot more. +[WARNING] +==== +When using `git svn`, you are still limited by Subversion's simpler model. Avoid complex Git merges if you plan to `dcommit` them back to SVN, as Subversion can't store Git's rich branching data. Keep your history linear until you make the final move to a true Git server. +==== diff --git a/book/09-git-and-other-scms/sections/import-custom.asc b/book/09-git-and-other-scms/sections/import-custom.asc index 726f3d8f4..5249110fb 100644 --- a/book/09-git-and-other-scms/sections/import-custom.asc +++ b/book/09-git-and-other-scms/sections/import-custom.asc @@ -1,371 +1,45 @@ [[_custom_importer]] -==== A Custom Importer +=== A Custom Importer +tag::concept[] (((git commands, fast-import))) -(((Importing, from others))) -If your system isn't one of the above, you should look for an importer online – quality importers are available for many other systems, including CVS, Clear Case, Visual Source Safe, even a directory of archives. -If none of these tools works for you, you have a more obscure tool, or you otherwise need a more custom importing process, you should use `git fast-import`. -This command reads simple instructions from stdin to write specific Git data. -It's much easier to create Git objects this way than to run the raw Git commands or try to write the raw objects (see <<ch10-git-internals#ch10-git-internals>> for more information). -This way, you can write an import script that reads the necessary information out of the system you're importing from and prints straightforward instructions to stdout. -You can then run this program and pipe its output through `git fast-import`. +What if Nora has a very old project that was never in a version control system? Perhaps it’s just a directory full of folders with names like `research_back_2015_05_12`. She wants to bring these snapshots into Git to preserve her "original" design decisions. -To quickly demonstrate, you'll write a simple importer. -Suppose you work in `current`, you back up your project by occasionally copying the directory into a time-stamped `back_YYYY_MM_DD` backup directory, and you want to import this into Git. -Your directory structure looks like this: +If no pre-built importer exists, she can use **`git fast-import`**. This command reads simple text instructions from "standard input" and builds Git objects directly. It’s Nora’s "direct line" into the Git database. -[source,console] ----- -$ ls /opt/import_from -back_2014_01_02 -back_2014_01_04 -back_2014_01_14 -back_2014_02_03 -current ----- - -In order to import a Git directory, you need to review how Git stores its data. -As you may remember, Git is fundamentally a linked list of commit objects that point to a snapshot of content. -All you have to do is tell `fast-import` what the content snapshots are, what commit data points to them, and the order they go in. -Your strategy will be to go through the snapshots one at a time and create commits with the contents of each directory, linking each commit back to the previous one. - -As we did in <<ch08-customizing-git#_an_example_git_enforced_policy>>, we'll write this in Ruby, because it's what we generally work with and it tends to be easy to read. -You can write this example pretty easily in anything you're familiar with – it just needs to print the appropriate information to `stdout`. -And, if you are running on Windows, this means you'll need to take special care to not introduce carriage returns at the end your lines – `git fast-import` is very particular about just wanting line feeds (LF) not the carriage return line feeds (CRLF) that Windows uses. - -To begin, you'll change into the target directory and identify every subdirectory, each of which is a snapshot that you want to import as a commit. -You'll change into each subdirectory and print the commands necessary to export it. -Your basic main loop looks like this: - -[source,ruby] ----- -last_mark = nil - -# loop through the directories -Dir.chdir(ARGV[0]) do - Dir.glob("*").each do |dir| - next if File.file?(dir) - - # move into the target directory - Dir.chdir(dir) do - last_mark = print_export(dir, last_mark) - end - end -end ----- - -You run `print_export` inside each directory, which takes the manifest and mark of the previous snapshot and returns the manifest and mark of this one; that way, you can link them properly. -"`Mark`" is the `fast-import` term for an identifier you give to a commit; as you create commits, you give each one a mark that you can use to link to it from other commits. -So, the first thing to do in your `print_export` method is generate a mark from the directory name: - -[source,ruby] ----- -mark = convert_dir_to_mark(dir) ----- - -You'll do this by creating an array of directories and using the index value as the mark, because a mark must be an integer. -Your method looks like this: - -[source,ruby] ----- -$marks = [] -def convert_dir_to_mark(dir) - if !$marks.include?(dir) - $marks << dir - end - ($marks.index(dir) + 1).to_s -end ----- - -Now that you have an integer representation of your commit, you need a date for the commit metadata. -Because the date is expressed in the name of the directory, you'll parse it out. -The next line in your `print_export` file is: - -[source,ruby] ----- -date = convert_dir_to_date(dir) ----- - -where `convert_dir_to_date` is defined as: - -[source,ruby] ----- -def convert_dir_to_date(dir) - if dir == 'current' - return Time.now().to_i - else - dir = dir.gsub('back_', '') - (year, month, day) = dir.split('_') - return Time.local(year, month, day).to_i - end -end ----- - -That returns an integer value for the date of each directory. -The last piece of meta-information you need for each commit is the committer data, which you hardcode in a global variable: - -[source,ruby] ----- -$author = 'John Doe <john@example.com>' ----- - -Now you're ready to begin printing out the commit data for your importer. -The initial information states that you're defining a commit object and what branch it's on, followed by the mark you've generated, the committer information and commit message, and then the previous commit, if any. -The code looks like this: - -[source,ruby] ----- -# print the import information -puts 'commit refs/heads/master' -puts 'mark :' + mark -puts "committer #{$author} #{date} -0700" -export_data('imported from ' + dir) -puts 'from :' + last_mark if last_mark ----- - -You hardcode the time zone (-0700) because doing so is easy. -If you're importing from another system, you must specify the time zone as an offset. -The commit message must be expressed in a special format: - -[source] ----- -data (size)\n(contents) ----- - -The format consists of the word data, the size of the data to be read, a newline, and finally the data. -Because you need to use the same format to specify the file contents later, you create a helper method, `export_data`: - -[source,ruby] ----- -def export_data(string) - print "data #{string.size}\n#{string}" -end ----- - -All that's left is to specify the file contents for each snapshot. -This is easy, because you have each one in a directory – you can print out the `deleteall` command followed by the contents of each file in the directory. -Git will then record each snapshot appropriately: +==== The Snapshot Strategy +tag::walkthrough[] -[source,ruby] +Nora has a directory of old research backups: +[source,text] ---- -puts 'deleteall' -Dir.glob("**/*").each do |file| - next if !File.file?(file) - inline_data(file) -end +$ ls /opt/old_archives +research_2015_01_02 +research_2015_02_14 +research_2016_03_10 ---- -Note: Because many systems think of their revisions as changes from one commit to another, fast-import can also take commands with each commit to specify which files have been added, removed, or modified and what the new contents are. -You could calculate the differences between snapshots and provide only this data, but doing so is more complex – you may as well give Git all the data and let it figure it out. -If this is better suited to your data, check the `fast-import` man page for details about how to provide your data in this manner. +She writes a small script (in Ruby or Python) that loops through these directories and prints out a series of instructions for Git. For each folder, the script says: +1. **Commit:** Create a new checkpoint. +2. **Date:** Use the date from the folder name. +3. **Content:** Add all files from this folder. +4. **From:** Link it to the previous checkpoint. -The format for listing the new file contents or specifying a modified file with the new contents is as follows: +==== Running the Import +tag::procedure[] -[source] ----- -M 644 inline path/to/file -data (size) -(file contents) ----- - -Here, 644 is the mode (if you have executable files, you need to detect and specify 755 instead), and inline says you'll list the contents immediately after this line. -Your `inline_data` method looks like this: - -[source,ruby] ----- -def inline_data(file, code = 'M', mode = '644') - content = File.read(file) - puts "#{code} #{mode} inline #{file}" - export_data(content) -end ----- - -You reuse the `export_data` method you defined earlier, because it's the same as the way you specified your commit message data. - -The last thing you need to do is to return the current mark so it can be passed to the next iteration: - -[source,ruby] ----- -return mark ----- +Nora pipes the output of her script directly into Git: -[NOTE] -==== -If you are running on Windows you'll need to make sure that you add one extra step. -As mentioned before, Windows uses CRLF for new line characters while `git fast-import` expects only LF. -To get around this problem and make `git fast-import` happy, you need to tell ruby to use LF instead of CRLF: - -[source,ruby] ----- -$stdout.binmode ----- -==== - -That's it. -Here's the script in its entirety: - -[source,ruby] +[source,bash] ---- -#!/usr/bin/env ruby - -$stdout.binmode -$author = "John Doe <john@example.com>" - -$marks = [] -def convert_dir_to_mark(dir) - if !$marks.include?(dir) - $marks << dir - end - ($marks.index(dir)+1).to_s -end - -def convert_dir_to_date(dir) - if dir == 'current' - return Time.now().to_i - else - dir = dir.gsub('back_', '') - (year, month, day) = dir.split('_') - return Time.local(year, month, day).to_i - end -end - -def export_data(string) - print "data #{string.size}\n#{string}" -end - -def inline_data(file, code='M', mode='644') - content = File.read(file) - puts "#{code} #{mode} inline #{file}" - export_data(content) -end - -def print_export(dir, last_mark) - date = convert_dir_to_date(dir) - mark = convert_dir_to_mark(dir) - - puts 'commit refs/heads/master' - puts "mark :#{mark}" - puts "committer #{$author} #{date} -0700" - export_data("imported from #{dir}") - puts "from :#{last_mark}" if last_mark - - puts 'deleteall' - Dir.glob("**/*").each do |file| - next if !File.file?(file) - inline_data(file) - end - mark -end - -# Loop through the directories -last_mark = nil -Dir.chdir(ARGV[0]) do - Dir.glob("*").each do |dir| - next if File.file?(dir) - - # move into the target directory - Dir.chdir(dir) do - last_mark = print_export(dir, last_mark) - end - end -end ----- - -If you run this script, you'll get content that looks something like this: - -[source,console] ----- -$ ruby import.rb /opt/import_from -commit refs/heads/master -mark :1 -committer John Doe <john@example.com> 1388649600 -0700 -data 29 -imported from back_2014_01_02deleteall -M 644 inline README.md -data 28 -# Hello - -This is my readme. -commit refs/heads/master -mark :2 -committer John Doe <john@example.com> 1388822400 -0700 -data 29 -imported from back_2014_01_04from :1 -deleteall -M 644 inline main.rb -data 34 -#!/bin/env ruby - -puts "Hey there" -M 644 inline README.md -(...) ----- - -To run the importer, pipe this output through `git fast-import` while in the Git directory you want to import into. -You can create a new directory and then run `git init` in it for a starting point, and then run your script: - -[source,console] ----- -$ git init -Initialized empty Git repository in /opt/import_to/.git/ -$ ruby import.rb /opt/import_from | git fast-import -git-fast-import statistics: ---------------------------------------------------------------------- -Alloc'd objects: 5000 -Total objects: 13 ( 6 duplicates ) - blobs : 5 ( 4 duplicates 3 deltas of 5 attempts) - trees : 4 ( 1 duplicates 0 deltas of 4 attempts) - commits: 4 ( 1 duplicates 0 deltas of 0 attempts) - tags : 0 ( 0 duplicates 0 deltas of 0 attempts) -Total branches: 1 ( 1 loads ) - marks: 1024 ( 5 unique ) - atoms: 2 -Memory total: 2344 KiB - pools: 2110 KiB - objects: 234 KiB ---------------------------------------------------------------------- -pack_report: getpagesize() = 4096 -pack_report: core.packedGitWindowSize = 1073741824 -pack_report: core.packedGitLimit = 8589934592 -pack_report: pack_used_ctr = 10 -pack_report: pack_mmap_calls = 5 -pack_report: pack_open_windows = 2 / 2 -pack_report: pack_mapped = 1457 / 1457 ---------------------------------------------------------------------- ----- - -As you can see, when it completes successfully, it gives you a bunch of statistics about what it accomplished. -In this case, you imported 13 objects total for 4 commits into 1 branch. -Now, you can run `git log` to see your new history: - -[source,console] ----- -$ git log -2 -commit 3caa046d4aac682a55867132ccdfbe0d3fdee498 -Author: John Doe <john@example.com> -Date: Tue Jul 29 19:39:04 2014 -0700 - - imported from current - -commit 4afc2b945d0d3c8cd00556fbe2e8224569dc9def -Author: John Doe <john@example.com> -Date: Mon Feb 3 01:00:00 2014 -0700 - - imported from back_2014_02_03 +$ ruby my_importer.rb /opt/old_archives | git fast-import ---- -There you go – a nice, clean Git repository. -It's important to note that nothing is checked out – you don't have any files in your working directory at first. -To get them, you must reset your branch to where `master` is now: +Git builds the history in seconds. Nora then runs a hard reset to see her files: -[source,console] +[source,bash] ---- -$ ls -$ git reset --hard master -HEAD is now at 3caa046 imported from current -$ ls -README.md main.rb +$ git reset --hard main ---- -You can do a lot more with the `fast-import` tool – handle different modes, binary data, multiple branches and merging, tags, progress indicators, and more. -A number of examples of more complex scenarios are available in the `contrib/fast-import` directory of the Git source code. +Now, when she runs `git log`, she sees a perfectly structured history of her 2015 research, as if she had been using Git all along. No matter how you’ve been storing your work in the past, `fast-import` ensures you can always graduate to a professional Git workflow. diff --git a/book/09-git-and-other-scms/sections/import-svn.asc b/book/09-git-and-other-scms/sections/import-svn.asc index 5ed4e8f5c..63d51c0cf 100644 --- a/book/09-git-and-other-scms/sections/import-svn.asc +++ b/book/09-git-and-other-scms/sections/import-svn.asc @@ -1,144 +1,54 @@ -==== Subversion +[[_migrating_svn]] +=== Migrating from Subversion +tag::procedure[] -(((Subversion))) -(((Importing, from Subversion))) -If you read the previous section about using `git svn`, you can easily use those instructions to `git svn clone` a repository; then, stop using the Subversion server, push to a new Git server, and start using that. -If you want the history, you can accomplish that as quickly as you can pull the data out of the Subversion server (which may take a while). +Once Nora convinced her team to move to Git permanently, she wanted to perform a "clean" migration. This means bringing over all the old research history but removing the messy artifacts of the Subversion server. -However, the import isn't perfect; and because it will take so long, you may as well do it right. -The first problem is the author information. -In Subversion, each person committing has a user on the system who is recorded in the commit information. -The examples in the previous section show `schacon` in some places, such as the `blame` output and the `git svn log`. -If you want to map this to better Git author data, you need a mapping from the Subversion users to the Git authors. -Create a file called `users.txt` that has this mapping in a format like this: +#### 1. Mapping Authors +In Subversion, Nora’s username might have been just `nora`. On GitHub, her identity is `Nora UX <nora@sketchspark.io>`. To ensure the history looks professional, she creates a `users.txt` file to map the old names to the new ones: -[source] +[source,text] ---- -schacon = Scott Chacon <schacon@geemail.com> -selse = Someo Nelse <selse@geemail.com> +nora = Nora UX <nora@sketchspark.io> +sam_ui = Sam UI <sam@sketchspark.io> +priya = Priya Illustrator <priya@sketchspark.io> ---- -To get a list of the author names that SVN uses, you can run this: +#### 2. The Clean Import +Nora uses `git svn clone` again, but this time she passes her authors file and tells Git not to include the legacy SVN metadata: -[source,console] +[source,bash] ---- -$ svn log --xml --quiet | grep author | sort -u | \ - perl -pe 's/.*>(.*?)<.*/$1 = /' +$ git svn clone https://agency-server.com/svn/project-x \ + --authors-file=users.txt --no-metadata -s sketchspark-fresh ---- -That generates the log output in XML format, then keeps only the lines with author information, discards duplicates, strips out the XML tags. -Obviously this only works on a machine with `grep`, `sort`, and `perl` installed. -Then, redirect that output into your `users.txt` file so you can add the equivalent Git user data next to each entry. +The `--no-metadata` flag is crucial—it prevents Git from adding a "git-svn-id" string to every single commit message, keeping the SketchSpark history clean. -[NOTE] -==== -If you're trying this on a Windows machine, this is the point where you'll run into trouble. -Microsoft have provided some good advice and samples at https://learn.microsoft.com/en-us/azure/devops/repos/git/perform-migration-from-svn-to-git[^]. -==== +#### 3. Post-Import Cleanup +Subversion tags and branches are imported as "remote" references. Nora runs a quick script to turn them into real Git tags and local branches: -You can provide this file to `git svn` to help it map the author data more accurately. -You can also tell `git svn` not to include the metadata that Subversion normally imports, by passing `--no-metadata` to the `clone` or `init` command. -The metadata includes a `git-svn-id` inside each commit message that Git will generate during import. -This can bloat your Git log and might make it a bit unclear. - -[NOTE] -==== -You need to keep the metadata when you want to mirror commits made in the Git repository back into the original SVN repository. -If you don't want the synchronization in your commit log, feel free to omit the `--no-metadata` parameter. -==== - -This makes your `import` command look like this: - -[source,console] ----- -$ git svn clone http://my-project.googlecode.com/svn/ \ - --authors-file=users.txt --no-metadata --prefix "" -s my_project -$ cd my_project ----- - -Now you should have a nicer Subversion import in your `my_project` directory. -Instead of commits that look like this: - -[source] ----- -commit 37efa680e8473b615de980fa935944215428a35a -Author: schacon <schacon@4c93b258-373f-11de-be05-5f7a86268029> -Date: Sun May 3 00:12:22 2009 +0000 - - fixed install - go to trunk - - git-svn-id: https://my-project.googlecode.com/svn/trunk@94 4c93b258-373f-11de- - be05-5f7a86268029 +[source,bash] ---- +# Convert SVN remote tags to real Git tags +$ for t in $(git for-each-ref --format='%(refname:short)' refs/remotes/tags); do \ + git tag ${t/tags\//} $t && git branch -D -r $t; \ + done -they look like this: - -[source] ----- -commit 03a8785f44c8ea5cdb0e8834b7c8e6c469be2ff2 -Author: Scott Chacon <schacon@geemail.com> -Date: Sun May 3 00:12:22 2009 +0000 - - fixed install - go to trunk ----- - -Not only does the Author field look a lot better, but the `git-svn-id` is no longer there, either. - -You should also do a bit of post-import cleanup. -For one thing, you should clean up the weird references that `git svn` set up. -First you'll move the tags so they're actual tags rather than strange remote branches, and then you'll move the rest of the branches so they're local. - -To move the tags to be proper Git tags, run: - -[source,console] ----- -$ for t in $(git for-each-ref --format='%(refname:short)' refs/remotes/tags); do git tag ${t/tags\//} $t && git branch -D -r $t; done ----- - -This takes the references that were remote branches that started with `refs/remotes/tags/` and makes them real (lightweight) tags. - -Next, move the rest of the references under `refs/remotes` to be local branches: - -[source,console] ----- -$ for b in $(git for-each-ref --format='%(refname:short)' refs/remotes); do git branch $b refs/remotes/$b && git branch -D -r $b; done ----- - -It may happen that you'll see some extra branches which are suffixed by `@xxx` (where xxx is a number), while in Subversion you only see one branch. -This is actually a Subversion feature called "`peg-revisions`", which is something that Git simply has no syntactical counterpart for. -Hence, `git svn` simply adds the SVN version number to the branch name just in the same way as you would have written it in SVN to address the peg-revision of that branch. -If you do not care anymore about the peg-revisions, simply remove them: - -[source,console] ----- -$ for p in $(git for-each-ref --format='%(refname:short)' | grep @); do git branch -D $p; done ----- - -Now all the old branches are real Git branches and all the old tags are real Git tags. - -There's one last thing to clean up. -Unfortunately, `git svn` creates an extra branch named `trunk`, which maps to Subversion's default branch, but the `trunk` ref points to the same place as `master`. -Since `master` is more idiomatically Git, here's how to remove the extra branch: - -[source,console] ----- -$ git branch -d trunk ----- - -The last thing to do is add your new Git server as a remote and push to it. -Here is an example of adding your server as a remote: - -[source,console] ----- -$ git remote add origin git@my-git-server:myrepository.git +# Convert SVN remote branches to local Git branches +$ for b in $(git for-each-ref --format='%(refname:short)' refs/remotes); do \ + git branch $b refs/remotes/$b && git branch -D -r $b; \ + done ---- -Because you want all your branches and tags to go up, you can now run this: +#### 4. The Final Push +Finally, Nora adds the new SketchSpark GitHub repository as a remote and pushes the entire history: -[source,console] +[source,bash] ---- +$ git remote add origin https://github.com/sketchspark/sketchspark.git $ git push origin --all $ git push origin --tags ---- -All your branches and tags should be on your new Git server in a nice, clean import. +The migration is complete. Years of agency research and design decisions are now safely stored in a modern, collaborative environment on GitHub. diff --git a/book/10-git-internals/sections/maintenance.asc b/book/10-git-internals/sections/maintenance.asc index d4e53081f..cd82c6b16 100644 --- a/book/10-git-internals/sections/maintenance.asc +++ b/book/10-git-internals/sections/maintenance.asc @@ -1,353 +1,55 @@ === Maintenance and Data Recovery +tag::concept[] -Occasionally, you may have to do some cleanup – make a repository more compact, clean up an imported repository, or recover lost work. -This section will cover some of these scenarios. +Occasionally, Nora may need to do some housekeeping to keep the SketchSpark repository running fast, or she might need to perform a "rescue operation" to recover a piece of work she thought was gone. -[[_git_gc]] -==== Maintenance +#### Maintenance: Housekeeping +tag::procedure[] -Occasionally, Git automatically runs a command called "`auto gc`". -Most of the time, this command does nothing. -However, if there are too many loose objects (objects not in a packfile) or too many packfiles, Git launches a full-fledged `git gc` command. -The "`gc`" stands for garbage collect, and the command does a number of things: it gathers up all the loose objects and places them in packfiles, it consolidates packfiles into one big packfile, and it removes objects that aren't reachable from any commit and are a few months old. +(((git commands, gc))) +As Nora’s project grows, the `.git/objects` folder can become full of thousands of small files. To keep things efficient, Git occasionally runs **Garbage Collection (GC)**. -You can run `auto gc` manually as follows: +Nora can run this manually to "pack" her objects into compact binary files: -[source,console] ----- -$ git gc --auto ----- - -Again, this generally does nothing. -You must have around 7,000 loose objects or more than 50 packfiles for Git to fire up a real `gc` command. -You can modify these limits with the `gc.auto` and `gc.autopacklimit` config settings, respectively. - -The other thing `gc` will do is pack up your references into a single file. -Suppose your repository contains the following branches and tags: - -[source,console] ----- -$ find .git/refs -type f -.git/refs/heads/experiment -.git/refs/heads/master -.git/refs/tags/v1.0 -.git/refs/tags/v1.1 ----- - -If you run `git gc`, you'll no longer have these files in the `refs` directory. -Git will move them for the sake of efficiency into a file named `.git/packed-refs` that looks like this: - -[source,console] ----- -$ cat .git/packed-refs -# pack-refs with: peeled fully-peeled -cac0cab538b970a37ea1e769cbbde608743bc96d refs/heads/experiment -ab1afef80fac8e34258ff41fc1b867c702daa24b refs/heads/master -cac0cab538b970a37ea1e769cbbde608743bc96d refs/tags/v1.0 -9585191f37f7b0fb9444f35a9bf50de191beadc2 refs/tags/v1.1 -^1a410efbd13591db07496601ebc7a059dd55cfe9 ----- - -If you update a reference, Git doesn't edit this file but instead writes a new file to `refs/heads`. -To get the appropriate SHA-1 for a given reference, Git checks for that reference in the `refs` directory and then checks the `packed-refs` file as a fallback. -So if you can't find a reference in the `refs` directory, it's probably in your `packed-refs` file. - -Notice the last line of the file, which begins with a `^`. -This means the tag directly above is an annotated tag and that line is the commit that the annotated tag points to. - -[[_data_recovery]] -==== Data Recovery - -At some point in your Git journey, you may accidentally lose a commit. -Generally, this happens because you force-delete a branch that had work on it, and it turns out you wanted the branch after all; or you hard-reset a branch, thus abandoning commits that you wanted something from. -Assuming this happens, how can you get your commits back? - -Here's an example that hard-resets the `master` branch in your test repository to an older commit and then recovers the lost commits. -First, let's review where your repository is at this point: - -[source,console] ----- -$ git log --pretty=oneline -ab1afef80fac8e34258ff41fc1b867c702daa24b Modify repo.rb a bit -484a59275031909e19aadb7c92262719cfcdf19a Create repo.rb -1a410efbd13591db07496601ebc7a059dd55cfe9 Third commit -cac0cab538b970a37ea1e769cbbde608743bc96d Second commit -fdf4fc3344e67ab068f836878b6c4951e3b15f3d First commit ----- - -Now, move the `master` branch back to the middle commit: - -[source,console] ----- -$ git reset --hard 1a410efbd13591db07496601ebc7a059dd55cfe9 -HEAD is now at 1a410ef Third commit -$ git log --pretty=oneline -1a410efbd13591db07496601ebc7a059dd55cfe9 Third commit -cac0cab538b970a37ea1e769cbbde608743bc96d Second commit -fdf4fc3344e67ab068f836878b6c4951e3b15f3d First commit ----- - -You've effectively lost the top two commits – you have no branch from which those commits are reachable. -You need to find the latest commit SHA-1 and then add a branch that points to it. -The trick is finding that latest commit SHA-1 – it's not like you've memorized it, right? - -Often, the quickest way is to use a tool called `git reflog`. -As you're working, Git silently records what your HEAD is every time you change it. -Each time you commit or change branches, the reflog is updated. -The reflog is also updated by the `git update-ref` command, which is another reason to use it instead of just writing the SHA-1 value to your ref files, as we covered in <<ch10-git-internals#_git_refs>>. -You can see where you've been at any time by running `git reflog`: - -[source,console] ----- -$ git reflog -1a410ef HEAD@{0}: reset: moving to 1a410ef -ab1afef HEAD@{1}: commit: Modify repo.rb a bit -484a592 HEAD@{2}: commit: Create repo.rb ----- - -Here we can see the two commits that we have had checked out, however there is not much information here. -To see the same information in a much more useful way, we can run `git log -g`, which will give you a normal log output for your reflog. - -[source,console] ----- -$ git log -g -commit 1a410efbd13591db07496601ebc7a059dd55cfe9 -Reflog: HEAD@{0} (Scott Chacon <schacon@gmail.com>) -Reflog message: updating HEAD -Author: Scott Chacon <schacon@gmail.com> -Date: Fri May 22 18:22:37 2009 -0700 - - Third commit - -commit ab1afef80fac8e34258ff41fc1b867c702daa24b -Reflog: HEAD@{1} (Scott Chacon <schacon@gmail.com>) -Reflog message: updating HEAD -Author: Scott Chacon <schacon@gmail.com> -Date: Fri May 22 18:15:24 2009 -0700 - - Modify repo.rb a bit ----- - -It looks like the bottom commit is the one you lost, so you can recover it by creating a new branch at that commit. -For example, you can start a branch named `recover-branch` at that commit (ab1afef): - -[source,console] ----- -$ git branch recover-branch ab1afef -$ git log --pretty=oneline recover-branch -ab1afef80fac8e34258ff41fc1b867c702daa24b Modify repo.rb a bit -484a59275031909e19aadb7c92262719cfcdf19a Create repo.rb -1a410efbd13591db07496601ebc7a059dd55cfe9 Third commit -cac0cab538b970a37ea1e769cbbde608743bc96d Second commit -fdf4fc3344e67ab068f836878b6c4951e3b15f3d First commit ----- - -Cool – now you have a branch named `recover-branch` that is where your `master` branch used to be, making the first two commits reachable again. -Next, suppose your loss was for some reason not in the reflog – you can simulate that by removing `recover-branch` and deleting the reflog. -Now the first two commits aren't reachable by anything: - -[source,console] ----- -$ git branch -D recover-branch -$ rm -Rf .git/logs/ ----- - -Because the reflog data is kept in the `.git/logs/` directory, you effectively have no reflog. -How can you recover that commit at this point? -One way is to use the `git fsck` utility, which checks your database for integrity. -If you run it with the `--full` option, it shows you all objects that aren't pointed to by another object: - -[source,console] ----- -$ git fsck --full -Checking object directories: 100% (256/256), done. -Checking objects: 100% (18/18), done. -dangling blob d670460b4b4aece5915caf5c68d12f560a9fe3e4 -dangling commit ab1afef80fac8e34258ff41fc1b867c702daa24b -dangling tree aea790b9a58f6cf6f2804eeac9f0abbe9631e4c9 -dangling blob 7108f7ecb345ee9d0084193f147cdad4d2998293 ----- - -In this case, you can see your missing commit after the string "`dangling commit`". -You can recover it the same way, by adding a branch that points to that SHA-1. - -[[_removing_objects]] -==== Removing Objects - -There are a lot of great things about Git, but one feature that can cause issues is the fact that a `git clone` downloads the entire history of the project, including every version of every file. -This is fine if the whole thing is source code, because Git is highly optimized to compress that data efficiently. -However, if someone at any point in the history of your project added a single huge file, every clone for all time will be forced to download that large file, even if it was removed from the project in the very next commit. -Because it's reachable from the history, it will always be there. - -This can be a huge problem when you're converting Subversion or Perforce repositories into Git. -Because you don't download the whole history in those systems, this type of addition carries few consequences. -If you did an import from another system or otherwise find that your repository is much larger than it should be, here is how you can find and remove large objects. - -*Be warned: this technique is destructive to your commit history.* -It rewrites every commit object since the earliest tree you have to modify to remove a large file reference. -If you do this immediately after an import, before anyone has started to base work on the commit, you're fine – otherwise, you have to notify all contributors that they must rebase their work onto your new commits. - -To demonstrate, you'll add a large file into your test repository, remove it in the next commit, find it, and remove it permanently from the repository. -First, add a large object to your history: - -[source,console] ----- -$ curl -L https://www.kernel.org/pub/software/scm/git/git-2.1.0.tar.gz > git.tgz -$ git add git.tgz -$ git commit -m 'Add git tarball' -[master 7b30847] Add git tarball - 1 file changed, 0 insertions(+), 0 deletions(-) - create mode 100644 git.tgz ----- - -Oops – you didn't want to add a huge tarball to your project. -Better get rid of it: - -[source,console] ----- -$ git rm git.tgz -rm 'git.tgz' -$ git commit -m 'Oops - remove large tarball' -[master dadf725] Oops - remove large tarball - 1 file changed, 0 insertions(+), 0 deletions(-) - delete mode 100644 git.tgz ----- - -Now, `gc` your database and see how much space you're using: - -[source,console] +[source,bash] ---- $ git gc -Counting objects: 17, done. -Delta compression using up to 8 threads. -Compressing objects: 100% (13/13), done. -Writing objects: 100% (17/17), done. -Total 17 (delta 1), reused 10 (delta 0) ---- -You can run the `count-objects` command to quickly see how much space you're using: +This command does two things: +1. **Consolidation:** It bundles many "loose" objects into a single compressed **Packfile**, significantly reducing disk usage. +2. **Pruning:** It removes objects that are truly no longer needed (like temporary blobs from weeks ago that were never committed). -[source,console] ----- -$ git count-objects -v -count: 7 -size: 32 -in-pack: 17 -packs: 1 -size-pack: 4868 -prune-packable: 0 -garbage: 0 -size-garbage: 0 ----- - -The `size-pack` entry is the size of your packfiles in kilobytes, so you're using almost 5MB. -Before the last commit, you were using closer to 2K – clearly, removing the file from the previous commit didn't remove it from your history. -Every time anyone clones this repository, they will have to clone all 5MB just to get this tiny project, because you accidentally added a big file. -Let's get rid of it. - -First you have to find it. -In this case, you already know what file it is. -But suppose you didn't; how would you identify what file or files were taking up so much space? -If you run `git gc`, all the objects are in a packfile; you can identify the big objects by running another plumbing command called `git verify-pack` and sorting on the third field in the output, which is file size. -You can also pipe it through the `tail` command because you're only interested in the last few largest files: - -[source,console] ----- -$ git verify-pack -v .git/objects/pack/pack-29…69.idx \ - | sort -k 3 -n \ - | tail -3 -dadf7258d699da2c8d89b09ef6670edb7d5f91b4 commit 229 159 12 -033b4468fa6b2a9547a70d88d1bbe8bf3f9ed0d5 blob 22044 5792 4977696 -82c99a3e86bb1267b236a4b6eff7868d97489af1 blob 4975916 4976258 1438 ----- - -The big object is at the bottom: 5MB. -To find out what file it is, you'll use the `rev-list` command, which you used briefly in <<ch08-customizing-git#_enforcing_commit_message_format>>. -If you pass `--objects` to `rev-list`, it lists all the commit SHA-1s and also the blob SHA-1s with the file paths associated with them. -You can use this to find your blob's name: - -[source,console] ----- -$ git rev-list --objects --all | grep 82c99a3 -82c99a3e86bb1267b236a4b6eff7868d97489af1 git.tgz ----- +For Nora, `git gc` is like organizing her physical studio—everything is tucked away in neat, efficient boxes, making the repository faster to clone and push. -Now, you need to remove this file from all trees in your past. -You can easily see what commits modified this file: +#### Data Recovery: Your Work Is Never Truly Lost +tag::walkthrough[] -[source,console] ----- -$ git log --oneline --branches -- git.tgz -dadf725 Oops - remove large tarball -7b30847 Add git tarball ----- +(((reflog, recovery))) +This is the moment Nora has been waiting for. Suppose she accidentally deleted a branch containing three days of intense layout explorations for the SketchSpark results screen. She thinks it's gone. -You must rewrite all the commits downstream from `7b30847` to fully remove this file from your Git history. -To do so, you use `filter-branch`, which you used in <<ch07-git-tools#_rewriting_history>>: +But Nora remembers her training. She knows that as long as she committed that work once, the objects are still in her database. She uses the **RefLog** to find them. -[source,console] +[source,bash] ---- -$ git filter-branch --index-filter \ - 'git rm --ignore-unmatch --cached git.tgz' -- 7b30847^.. -Rewrite 7b30847d080183a1ab7d18fb202473b3096e9f34 (1/2)rm 'git.tgz' -Rewrite dadf7258d699da2c8d89b09ef6670edb7d5f91b4 (2/2) -Ref 'refs/heads/master' was rewritten +$ git reflog ---- -The `--index-filter` option is similar to the `--tree-filter` option used in <<ch07-git-tools#_rewriting_history>>, except that instead of passing a command that modifies files checked out on disk, you're modifying your staging area or index each time. - -Rather than remove a specific file with something like `rm file`, you have to remove it with `git rm --cached` – you must remove it from the index, not from disk. -The reason to do it this way is speed – because Git doesn't have to check out each revision to disk before running your filter, the process can be much, much faster. -You can accomplish the same task with `--tree-filter` if you want. -The `--ignore-unmatch` option to `git rm` tells it not to error out if the pattern you're trying to remove isn't there. -Finally, you ask `filter-branch` to rewrite your history only from the `7b30847` commit up, because you know that is where this problem started. -Otherwise, it will start from the beginning and will unnecessarily take longer. +Git shows her a list of every move she’s made. She sees the entry: +`ca82a6d HEAD@{5}: commit: [Design: Results] Prototype new grid` -Your history no longer contains a reference to that file. -However, your reflog and a new set of refs that Git added when you did the `filter-branch` under `.git/refs/original` still do, so you have to remove them and then repack the database. -You need to get rid of anything that has a pointer to those old commits before you repack: +Even though the branch is deleted, the **SHA-1 ID** (`ca82a6d`) is still right there. To get her work back, Nora just creates a new branch pointing to that ID: -[source,console] +[source,bash] ---- -$ rm -Rf .git/refs/original -$ rm -Rf .git/logs/ -$ git gc -Counting objects: 15, done. -Delta compression using up to 8 threads. -Compressing objects: 100% (11/11), done. -Writing objects: 100% (15/15), done. -Total 15 (delta 1), reused 12 (delta 0) +$ git branch recover-results ca82a6d ---- -Let's see how much space you saved. +Instantly, her three days of work are back. -[source,console] ----- -$ git count-objects -v -count: 11 -size: 4904 -in-pack: 15 -packs: 1 -size-pack: 8 -prune-packable: 0 -garbage: 0 -size-garbage: 0 ----- +#### Final Peace of Mind +tag::overview[] -The packed repository size is down to 8K, which is much better than 5MB. -You can see from the size value that the big object is still in your loose objects, so it's not gone; but it won't be transferred on a push or subsequent clone, which is what is important. -If you really wanted to, you could remove the object completely by running `git prune` with the `--expire` option: +This is the ultimate lesson of the SketchSpark journey. Git’s internal architecture—its immutable objects and persistent logs—means that Nora, Sam, and Priya can experiment with total freedom. They can try "dumb ideas," perform complex rebases, and push the boundaries of their design, knowing that Git is always holding the safety net. -[source,console] ----- -$ git prune --expire now -$ git count-objects -v -count: 0 -size: 0 -in-pack: 15 -packs: 1 -size-pack: 8 -prune-packable: 0 -garbage: 0 -size-garbage: 0 ----- +In the world of SketchSpark, **your work is never truly lost.** diff --git a/book/10-git-internals/sections/objects.asc b/book/10-git-internals/sections/objects.asc index 3182d9f9d..2b75cc8cd 100644 --- a/book/10-git-internals/sections/objects.asc +++ b/book/10-git-internals/sections/objects.asc @@ -1,437 +1,56 @@ [[_objects]] === Git Objects +tag::concept[] -Git is a content-addressable filesystem. -Great. -What does that mean? -It means that at the core of Git is a simple key-value data store. -What this means is that you can insert any kind of content into a Git repository, for which Git will hand you back a unique key you can use later to retrieve that content. +At its core, Git is a **content-addressable filesystem**. That sounds complex, but for Nora, it means something very simple: Git is a giant key-value store. You give Git some content (like a design brief), and Git gives you back a unique key. You can use that key to get your content back exactly as it was, forever. -As a demonstration, let's look at the plumbing command `git hash-object`, which takes some data, stores it in your `.git/objects` directory (the _object database_), and gives you back the unique key that now refers to that data object. +#### Blobs: The Raw Content +tag::procedure[] -First, you initialize a new Git repository and verify that there is (predictably) nothing in the `objects` directory: +(((blobs))) +Let’s look at how Git stores a single piece of research. Nora has a file called `notes.txt` containing the text "user interview 1". -[source,console] ----- -$ git init test -Initialized empty Git repository in /tmp/test/.git/ -$ cd test -$ find .git/objects -.git/objects -.git/objects/info -.git/objects/pack -$ find .git/objects -type f ----- - -Git has initialized the `objects` directory and created `pack` and `info` subdirectories in it, but there are no regular files. -Now, let's use `git hash-object` to create a new data object and manually store it in your new Git database: - -[source,console] ----- -$ echo 'test content' | git hash-object -w --stdin -d670460b4b4aece5915caf5c68d12f560a9fe3e4 ----- - -In its simplest form, `git hash-object` would take the content you handed to it and merely return the unique key that _would_ be used to store it in your Git database. -The `-w` option then tells the command to not simply return the key, but to write that object to the database. -Finally, the `--stdin` option tells `git hash-object` to get the content to be processed from stdin; otherwise, the command would expect a filename argument at the end of the command containing the content to be used. - -The output from the above command is a 40-character checksum hash. -This is the SHA-1 hash -- a checksum of the content you're storing plus a header, which you'll learn about in a bit. -Now you can see how Git has stored your data: - -[source,console] ----- -$ find .git/objects -type f -.git/objects/d6/70460b4b4aece5915caf5c68d12f560a9fe3e4 ----- - -If you again examine your `objects` directory, you can see that it now contains a file for that new content. -This is how Git stores the content initially -- as a single file per piece of content, named with the SHA-1 checksum of the content and its header. -The subdirectory is named with the first 2 characters of the SHA-1, and the filename is the remaining 38 characters. - -Once you have content in your object database, you can examine that content with the `git cat-file` command. -This command is sort of a Swiss army knife for inspecting Git objects. -Passing `-p` to `cat-file` instructs the command to first figure out the type of content, then display it appropriately: - -[source,console] ----- -$ git cat-file -p d670460b4b4aece5915caf5c68d12f560a9fe3e4 -test content ----- +She can use the plumbing command `git hash-object` to manually store this in her database: -Now, you can add content to Git and pull it back out again. -You can also do this with content in files. -For example, you can do some simple version control on a file. -First, create a new file and save its contents in your database: - -[source,console] +[source,bash] ---- -$ echo 'version 1' > test.txt -$ git hash-object -w test.txt +$ echo 'user interview 1' | git hash-object -w --stdin 83baae61804e65cc73a7201a7252750c76066a30 ---- -Then, write some new content to the file, and save it again: - -[source,console] ----- -$ echo 'version 2' > test.txt -$ git hash-object -w test.txt -1f7a7a472abf3dd9643fd615f6da379c4acb3e3a ----- - -Your object database now contains both versions of this new file (as well as the first content you stored there): - -[source,console] ----- -$ find .git/objects -type f -.git/objects/1f/7a7a472abf3dd9643fd615f6da379c4acb3e3a -.git/objects/83/baae61804e65cc73a7201a7252750c76066a30 -.git/objects/d6/70460b4b4aece5915caf5c68d12f560a9fe3e4 ----- - -At this point, you can delete your local copy of that `test.txt` file, then use Git to retrieve, from the object database, either the first version you saved: - -[source,console] ----- -$ git cat-file -p 83baae61804e65cc73a7201a7252750c76066a30 > test.txt -$ cat test.txt -version 1 ----- - -or the second version: - -[source,console] ----- -$ git cat-file -p 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a > test.txt -$ cat test.txt -version 2 ----- - -But remembering the SHA-1 key for each version of your file isn't practical; plus, you aren't storing the filename in your system -- just the content. -This object type is called a _blob_. -You can have Git tell you the object type of any object in Git, given its SHA-1 key, with `git cat-file -t`: - -[source,console] ----- -$ git cat-file -t 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a -blob ----- - -[[_tree_objects]] -==== Tree Objects - -The next type of Git object we'll examine is the _tree_, which solves the problem of storing the filename and also allows you to store a group of files together. -Git stores content in a manner similar to a UNIX filesystem, but a bit simplified. -All the content is stored as tree and blob objects, with trees corresponding to UNIX directory entries and blobs corresponding more or less to inodes or file contents. -A single tree object contains one or more entries, each of which is the SHA-1 hash of a blob or subtree with its associated mode, type, and filename. -For example, let's say you have a project where the most-recent tree looks something like: - -[source,console] ----- -$ git cat-file -p master^{tree} -100644 blob a906cb2a4a904a152e80877d4088654daad0c859 README -100644 blob 8f94139338f9404f26296befa88755fc2598c289 Rakefile -040000 tree 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 lib ----- - -The `master^{tree}` syntax specifies the tree object that is pointed to by the last commit on your `master` branch. -Notice that the `lib` subdirectory isn't a blob but a pointer to another tree: - -[source,console] ----- -$ git cat-file -p 99f1a6d12cb4b6f19c8655fca46c3ecf317074e0 -100644 blob 47c6340d6459e05787f644c2447d2595f5d3a54b simplegit.rb ----- - -[NOTE] -==== -Depending on what shell you use, you may encounter errors when using the `master^{tree}` syntax. - -In CMD on Windows, the `^` character is used for escaping, so you have to double it to avoid this: `git cat-file -p master^^{tree}`. -When using PowerShell, parameters using `{}` characters have to be quoted to avoid the parameter being parsed incorrectly: `git cat-file -p 'master^{tree}'`. - -If you're using ZSH, the `^` character is used for globbing, so you have to enclose the whole expression in quotes: `git cat-file -p "master^{tree}"`. -==== +Git returns a 40-character **SHA-1 hash**. This is the "ID" for that specific content. If Nora changes even one character, the hash will be completely different. -Conceptually, the data that Git is storing looks something like this: +Git stores this content in `.git/objects/83/baae61...`. To get it back, Nora uses `git cat-file`: -.Simple version of the Git data model -image::images/data-model-1.png[Simple version of the Git data model] - -You can fairly easily create your own tree. -Git normally creates a tree by taking the state of your staging area or index and writing a series of tree objects from it. -So, to create a tree object, you first have to set up an index by staging some files. -To create an index with a single entry -- the first version of your `test.txt` file -- you can use the plumbing command `git update-index`. -You use this command to artificially add the earlier version of the `test.txt` file to a new staging area. -You must pass it the `--add` option because the file doesn't yet exist in your staging area (you don't even have a staging area set up yet) and `--cacheinfo` because the file you're adding isn't in your directory but is in your database. -Then, you specify the mode, SHA-1, and filename: - -[source,console] ----- -$ git update-index --add --cacheinfo 100644 \ - 83baae61804e65cc73a7201a7252750c76066a30 test.txt ----- - -In this case, you're specifying a mode of `100644`, which means it's a normal file. -Other options are `100755`, which means it's an executable file; and `120000`, which specifies a symbolic link. -The mode is taken from normal UNIX modes but is much less flexible -- these three modes are the only ones that are valid for files (blobs) in Git (although other modes are used for directories and submodules). - -Now, you can use `git write-tree` to write the staging area out to a tree object. -No `-w` option is needed -- calling this command automatically creates a tree object from the state of the index if that tree doesn't yet exist: - -[source,console] ----- -$ git write-tree -d8329fc1cc938780ffdd9f94e0d364e0ea74f579 -$ git cat-file -p d8329fc1cc938780ffdd9f94e0d364e0ea74f579 -100644 blob 83baae61804e65cc73a7201a7252750c76066a30 test.txt +[source,bash] ---- - -You can also verify that this is a tree object using the same `git cat-file` command you saw earlier: - -[source,console] ----- -$ git cat-file -t d8329fc1cc938780ffdd9f94e0d364e0ea74f579 -tree +$ git cat-file -p 83baae6 +user interview 1 ---- -You'll now create a new tree with the second version of `test.txt` and a new file as well: +In Git terminology, this raw content object is called a **Blob**. It doesn't know its filename or where it lives in the folder structure—it only knows its content. -[source,console] ----- -$ echo 'new file' > new.txt -$ git update-index --cacheinfo 100644 \ - 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a test.txt -$ git update-index --add new.txt ----- +#### Trees: The Folder Structure +tag::concept[] -Your staging area now has the new version of `test.txt` as well as the new file `new.txt`. -Write out that tree (recording the state of the staging area or index to a tree object) and see what it looks like: +(((trees))) +If Blobs are the files, **Trees** are the folders. A Tree object maps filenames to Blobs. For the SketchSpark project, a Tree object might look like this: -[source,console] +[source,text] ---- -$ git write-tree -0155eb4229851634a0f03eb265b69f5a2d56f341 -$ git cat-file -p 0155eb4229851634a0f03eb265b69f5a2d56f341 -100644 blob fa49b077972391ad58037050f2a75f74e3671e92 new.txt -100644 blob 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a test.txt +100644 blob 83baae6... product-brief.md +040000 tree d8329fc... research/ ---- -Notice that this tree has both file entries and also that the `test.txt` SHA-1 is the "`version 2`" SHA-1 from earlier (`1f7a7a`). -Just for fun, you'll add the first tree as a subdirectory into this one. -You can read trees into your staging area by calling `git read-tree`. -In this case, you can read an existing tree into your staging area as a subtree by using the `--prefix` option with this command: - -[source,console] ----- -$ git read-tree --prefix=bak d8329fc1cc938780ffdd9f94e0d364e0ea74f579 -$ git write-tree -3c4e9cd789d88d8d89c1073707c3585e41b0e614 -$ git cat-file -p 3c4e9cd789d88d8d89c1073707c3585e41b0e614 -040000 tree d8329fc1cc938780ffdd9f94e0d364e0ea74f579 bak -100644 blob fa49b077972391ad58037050f2a75f74e3671e92 new.txt -100644 blob 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a test.txt ----- - -If you created a working directory from the new tree you just wrote, you would get the two files in the top level of the working directory and a subdirectory named `bak` that contained the first version of the `test.txt` file. -You can think of the data that Git contains for these structures as being like this: - -.The content structure of your current Git data -image::images/data-model-2.png[The content structure of your current Git data] - -[[_git_commit_objects]] -==== Commit Objects - -If you've done all of the above, you now have three trees that represent the different snapshots of your project that you want to track, but the earlier problem remains: you must remember all three SHA-1 values in order to recall the snapshots. -You also don't have any information about who saved the snapshots, when they were saved, or why they were saved. -This is the basic information that the commit object stores for you. - -To create a commit object, you call `commit-tree` and specify a single tree SHA-1 and which commit objects, if any, directly preceded it. -Start with the first tree you wrote: - -[source,console] ----- -$ echo 'First commit' | git commit-tree d8329f -fdf4fc3344e67ab068f836878b6c4951e3b15f3d ----- - -[NOTE] -==== -You will get a different hash value because of different creation time and author data. -Moreover, while in principle any commit object can be reproduced precisely given that data, historical details of this book's construction mean that the printed commit hashes might not correspond to the given commits. -Replace commit and tag hashes with your own checksums further in this chapter. -==== - -Now you can look at your new commit object with `git cat-file`: - -[source,console] ----- -$ git cat-file -p fdf4fc3 -tree d8329fc1cc938780ffdd9f94e0d364e0ea74f579 -author Scott Chacon <schacon@gmail.com> 1243040974 -0700 -committer Scott Chacon <schacon@gmail.com> 1243040974 -0700 - -First commit ----- - -The format for a commit object is simple: it specifies the top-level tree for the snapshot of the project at that point; the parent commits if any (the commit object described above does not have any parents); the author/committer information (which uses your `user.name` and `user.email` configuration settings and a timestamp); a blank line, and then the commit message. - -Next, you'll write the other two commit objects, each referencing the commit that came directly before it: - -[source,console] ----- -$ echo 'Second commit' | git commit-tree 0155eb -p fdf4fc3 -cac0cab538b970a37ea1e769cbbde608743bc96d -$ echo 'Third commit' | git commit-tree 3c4e9c -p cac0cab -1a410efbd13591db07496601ebc7a059dd55cfe9 ----- - -Each of the three commit objects points to one of the three snapshot trees you created. -Oddly enough, you have a real Git history now that you can view with the `git log` command, if you run it on the last commit SHA-1: - -[source,console] ----- -$ git log --stat 1a410e -commit 1a410efbd13591db07496601ebc7a059dd55cfe9 -Author: Scott Chacon <schacon@gmail.com> -Date: Fri May 22 18:15:24 2009 -0700 - - Third commit - - bak/test.txt | 1 + - 1 file changed, 1 insertion(+) - -commit cac0cab538b970a37ea1e769cbbde608743bc96d -Author: Scott Chacon <schacon@gmail.com> -Date: Fri May 22 18:14:29 2009 -0700 - - Second commit - - new.txt | 1 + - test.txt | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit fdf4fc3344e67ab068f836878b6c4951e3b15f3d -Author: Scott Chacon <schacon@gmail.com> -Date: Fri May 22 18:09:34 2009 -0700 - - First commit - - test.txt | 1 + - 1 file changed, 1 insertion(+) ----- - -Amazing. -You've just done the low-level operations to build up a Git history without using any of the front end commands. -This is essentially what Git does when you run the `git add` and `git commit` commands -- it stores blobs for the files that have changed, updates the index, writes out trees, and writes commit objects that reference the top-level trees and the commits that came immediately before them. -These three main Git objects -- the blob, the tree, and the commit -- are initially stored as separate files in your `.git/objects` directory. -Here are all the objects in the example directory now, commented with what they store: - -[source,console] ----- -$ find .git/objects -type f -.git/objects/01/55eb4229851634a0f03eb265b69f5a2d56f341 # tree 2 -.git/objects/1a/410efbd13591db07496601ebc7a059dd55cfe9 # commit 3 -.git/objects/1f/7a7a472abf3dd9643fd615f6da379c4acb3e3a # test.txt v2 -.git/objects/3c/4e9cd789d88d8d89c1073707c3585e41b0e614 # tree 3 -.git/objects/83/baae61804e65cc73a7201a7252750c76066a30 # test.txt v1 -.git/objects/ca/c0cab538b970a37ea1e769cbbde608743bc96d # commit 2 -.git/objects/d6/70460b4b4aece5915caf5c68d12f560a9fe3e4 # 'test content' -.git/objects/d8/329fc1cc938780ffdd9f94e0d364e0ea74f579 # tree 1 -.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92 # new.txt -.git/objects/fd/f4fc3344e67ab068f836878b6c4951e3b15f3d # commit 1 ----- - -If you follow all the internal pointers, you get an object graph something like this: - -.All the reachable objects in your Git directory -image::images/data-model-3.png[All the reachable objects in your Git directory] - -==== Object Storage - -We mentioned earlier that there is a header stored with every object you commit to your Git object database. -Let's take a minute to see how Git stores its objects. -You'll see how to store a blob object -- in this case, the string "`what is up, doc?`" -- interactively in the Ruby scripting language. - -You can start up interactive Ruby mode with the `irb` command: - -[source,console] ----- -$ irb ->> content = "what is up, doc?" -=> "what is up, doc?" ----- - -Git first constructs a header which starts by identifying the type of object -- in this case, a blob. -To that first part of the header, Git adds a space followed by the size in bytes of the content, and adding a final null byte: - -[source,console] ----- ->> header = "blob #{content.bytesize}\0" -=> "blob 16\u0000" ----- - -Git concatenates the header and the original content and then calculates the SHA-1 checksum of that new content. -You can calculate the SHA-1 value of a string in Ruby by including the SHA1 digest library with the `require` command and then calling `Digest::SHA1.hexdigest()` with the string: - -[source,console] ----- ->> store = header + content -=> "blob 16\u0000what is up, doc?" ->> require 'digest/sha1' -=> true ->> sha1 = Digest::SHA1.hexdigest(store) -=> "bd9dbf5aae1a3862dd1526723246b20206e5fc37" ----- - -Let's compare that to the output of `git hash-object`. -Here we use `echo -n` to prevent adding a newline to the input. - -[source,console] ----- -$ echo -n "what is up, doc?" | git hash-object --stdin -bd9dbf5aae1a3862dd1526723246b20206e5fc37 ----- - -Git compresses the new content with zlib, which you can do in Ruby with the zlib library. -First, you need to require the library and then run `Zlib::Deflate.deflate()` on the content: - -[source,console] ----- ->> require 'zlib' -=> true ->> zlib_content = Zlib::Deflate.deflate(store) -=> "x\x9CK\xCA\xC9OR04c(\xCFH,Q\xC8,V(-\xD0QH\xC9O\xB6\a\x00_\x1C\a\x9D" ----- - -Finally, you'll write your zlib-deflated content to an object on disk. -You'll determine the path of the object you want to write out (the first two characters of the SHA-1 value being the subdirectory name, and the last 38 characters being the filename within that directory). -In Ruby, you can use the `FileUtils.mkdir_p()` function to create the subdirectory if it doesn't exist. -Then, open the file with `File.open()` and write out the previously zlib-compressed content to the file with a `write()` call on the resulting file handle: - -[source,console] ----- ->> path = '.git/objects/' + sha1[0,2] + '/' + sha1[2,38] -=> ".git/objects/bd/9dbf5aae1a3862dd1526723246b20206e5fc37" ->> require 'fileutils' -=> true ->> FileUtils.mkdir_p(File.dirname(path)) -=> ".git/objects/bd" ->> File.open(path, 'w') { |f| f.write zlib_content } -=> 32 ----- +This Tree tells Git: "The file `product-brief.md` has the content of blob `83baae6`, and there is a subdirectory called `research/` whose structure is defined by another tree `d8329fc`." -Let's check the content of the object using `git cat-file`: +#### Commits: The Snapshots +tag::concept[] -[source,console] ---- -$ git cat-file -p bd9dbf5aae1a3862dd1526723246b20206e5fc37 -what is up, doc? ---- +(((commits, internals))) +Finally, we have **Commits**. A Commit object points to a single Tree (the state of the project at that moment) and includes metadata like Nora’s name, the date, and—most importantly—the ID of the commit that came before it (the parent). -That's it – you've created a valid Git blob object. +.The relationship between Commits, Trees, and Blobs +image::images/data-model-3.png[Git data model] -All Git objects are stored the same way, just with different types – instead of the string blob, the header will begin with commit or tree. -Also, although the blob content can be nearly anything, the commit and tree content are very specifically formatted. +By linking these objects together, Git builds a perfect, immutable record of Nora's design journey. Even if Nora deletes a file from her Sandbox, the Blob containing that work is still safely stored in the `.git/objects` folder. diff --git a/book/10-git-internals/sections/plumbing-porcelain.asc b/book/10-git-internals/sections/plumbing-porcelain.asc index 53b409554..6ab0538ff 100644 --- a/book/10-git-internals/sections/plumbing-porcelain.asc +++ b/book/10-git-internals/sections/plumbing-porcelain.asc @@ -1,37 +1,34 @@ [[_plumbing_porcelain]] === Plumbing and Porcelain +tag::concept[] -This book covers primarily how to use Git with 30 or so subcommands such as `checkout`, `branch`, `remote`, and so on. -But because Git was initially a toolkit for a version control system rather than a full user-friendly VCS, it has a number of subcommands that do low-level work and were designed to be chained together UNIX-style or called from scripts. -These commands are generally referred to as Git's "`plumbing`" commands, while the more user-friendly commands are called "`porcelain`" commands. +Throughout this book, Nora and her team have used about 30 different Git subcommands—`checkout`, `branch`, `remote`, `stash`, and so on. In the world of Git, these user-friendly tools are called **Porcelain** commands. Just like the polished porcelain of a bathroom fixture hides the complex pipes underneath, these commands hide the raw power of Git’s engine. -As you will have noticed by now, this book's first nine chapters deal almost exclusively with porcelain commands. -But in this chapter, you'll be dealing mostly with the lower-level plumbing commands, because they give you access to the inner workings of Git, and help demonstrate how and why Git does what it does. -Many of these commands aren't meant to be used manually on the command line, but rather to be used as building blocks for new tools and custom scripts. +In this final chapter, we’re going to peel back that porcelain and look at the **Plumbing**—the low-level commands that Git uses to move data around. While Nora doesn't need these for her daily design work, understanding them will give her total confidence that her work is safe and recoverable. -When you run `git init` in a new or existing directory, Git creates the `.git` directory, which is where almost everything that Git stores and manipulates is located. -If you want to back up or clone your repository, copying this single directory elsewhere gives you nearly everything you need. -This entire chapter basically deals with what you can see in this directory. -Here's what a newly-initialized `.git` directory typically looks like: +#### The Brain of the Project: The .git Directory +tag::concept[] -[source,console] +When Nora ran `git init` back in Chapter 2, Git created a hidden folder called `.git`. This single directory contains almost everything Git knows about the SketchSpark project. If Nora backs up this one folder, she has the entire history of her project. + +Inside a fresh SketchSpark repo, the `.git` directory looks like this: + +[source,bash] ---- $ ls -F1 -config -description -HEAD -hooks/ -info/ -objects/ -refs/ +HEAD # The pointer to your current branch +config # Your project-specific settings +description # (Used for GitWeb, safe to ignore) +hooks/ # Your design-ops automation scripts +info/ # Global patterns for ignoring files +objects/ # The database: where every design asset lives +refs/ # The pointers: where branches and tags live ---- -Depending on your version of Git, you may see some additional content there, but this is a fresh `git init` repository -- it's what you see by default. -The `description` file is used only by the GitWeb program, so don't worry about it. -The `config` file contains your project-specific configuration options, and the `info` directory keeps a global exclude file (((excludes))) for ignored patterns that you don't want to track in a `.gitignore` file. -The `hooks` directory contains your client- or server-side hook scripts, which are discussed in detail in <<ch08-customizing-git#_git_hooks>>. +There are four essential parts here that make the "SketchSpark time machine" work: +1. **objects/**: The core database. +2. **refs/**: The pointers to specific versions (branches/tags). +3. **HEAD**: Your current location in the timeline. +4. **index**: Your proposed next checkpoint (the Staging Area). -This leaves four important entries: the `HEAD` and (yet to be created) `index` files, and the `objects` and `refs` directories. -These are the core parts of Git. -The `objects` directory stores all the content for your database, the `refs` directory stores pointers into commit objects in that data (branches, tags, remotes and more), the `HEAD` file points to the branch you currently have checked out, and the `index` file is where Git stores your staging area information. -You'll now look at each of these sections in detail to see how Git operates. +By exploring these four areas, Nora will finally see how Git ensures that in the SketchSpark project, **your work is never truly lost.** diff --git a/book/10-git-internals/sections/refs.asc b/book/10-git-internals/sections/refs.asc index c8319084f..0830cf7d6 100644 --- a/book/10-git-internals/sections/refs.asc +++ b/book/10-git-internals/sections/refs.asc @@ -1,209 +1,51 @@ [[_git_refs]] === Git References +tag::concept[] -If you were interested in seeing the history of your repository reachable from commit, say, `1a410e`, you could run something like `git log 1a410e` to display that history, but you would still have to remember that `1a410e` is the commit you want to use as the starting point for that history. -Instead, it would be easier if you had a file in which you could store that SHA-1 value under a simple name so you could use that simple name rather than the raw SHA-1 value. +Now that Nora understands the database of Blobs, Trees, and Commits, she might wonder: "How does Git know which commit is the `main` branch?" -In Git, these simple names are called "`references`" or "`refs`"; you can find the files that contain those SHA-1 values in the `.git/refs` directory. -In the current project, this directory contains no files, but it does contain a simple structure: +The answer is surprisingly simple. In Git, a branch is just a **Reference**—a small text file that contains the 40-character SHA-1 ID of a commit. These files live in the `.git/refs` directory. -[source,console] ----- -$ find .git/refs -.git/refs -.git/refs/heads -.git/refs/tags -$ find .git/refs -type f ----- - -To create a new reference that will help you remember where your latest commit is, you can technically do something as simple as this: - -[source,console] ----- -$ echo 1a410efbd13591db07496601ebc7a059dd55cfe9 > .git/refs/heads/master ----- - -Now, you can use the head reference you just created instead of the SHA-1 value in your Git commands: - -[source,console] ----- -$ git log --pretty=oneline master -1a410efbd13591db07496601ebc7a059dd55cfe9 Third commit -cac0cab538b970a37ea1e769cbbde608743bc96d Second commit -fdf4fc3344e67ab068f836878b6c4951e3b15f3d First commit ----- +#### Branches: Movable Pointers +tag::procedure[] -You aren't encouraged to directly edit the reference files; instead, Git provides the safer command `git update-ref` to do this if you want to update a reference: +(((git commands, update-ref))) +When Nora makes a commit on her `main` branch, Git doesn't do anything complex. It just updates the file at `.git/refs/heads/main` with the ID of her new commit. -[source,console] ----- -$ git update-ref refs/heads/master 1a410efbd13591db07496601ebc7a059dd55cfe9 ----- +She can see this for herself: -That's basically what a branch in Git is: a simple pointer or reference to the head of a line of work. -To create a branch back at the second commit, you can do this: - -[source,console] ----- -$ git update-ref refs/heads/test cac0ca +[source,bash] ---- - -Your branch will contain only work from that commit down: - -[source,console] ----- -$ git log --pretty=oneline test -cac0cab538b970a37ea1e769cbbde608743bc96d Second commit -fdf4fc3344e67ab068f836878b6c4951e3b15f3d First commit +$ cat .git/refs/heads/main +ca82a6dff817ec66f44342007202690a93763949 ---- -Now, your Git database conceptually looks something like this: +That’s all a branch is: a pointer. This is why branching in Git is so lightweight and instantaneous. Creating a new branch just means creating a new 41-byte text file. -.Git directory objects with branch head references included -image::images/data-model-4.png[Git directory objects with branch head references included] +#### HEAD: Where Are You? +tag::concept[] -When you run commands like `git branch <branch>`, Git basically runs that `update-ref` command to add the SHA-1 of the last commit of the branch you're on into whatever new reference you want to create. +(((HEAD))) +Git also needs to know which branch Nora is currently using. For this, it uses a special file called **HEAD**. If Nora looks at her HEAD file: -[[ref_the_ref]] -==== The HEAD - -The question now is, when you run `git branch <branch>`, how does Git know the SHA-1 of the last commit? -The answer is the HEAD file. - -Usually the HEAD file is a symbolic reference to the branch you're currently on. -By symbolic reference, we mean that unlike a normal reference, it contains a pointer to another reference. - -However in some rare cases the HEAD file may contain the SHA-1 value of a Git object. -This happens when you checkout a tag, commit, or remote branch, which puts your repository in https://git-scm.com/docs/git-checkout#_detached_head["detached HEAD"^] state. - -If you look at the file, you'll normally see something like this: - -[source,console] ----- -$ cat .git/HEAD -ref: refs/heads/master ----- - -If you run `git checkout test`, Git updates the file to look like this: - -[source,console] +[source,bash] ---- $ cat .git/HEAD -ref: refs/heads/test +ref: refs/heads/main ---- -When you run `git commit`, it creates the commit object, specifying the parent of that commit object to be whatever SHA-1 value the reference in HEAD points to. +This tells Git: "Nora is currently on the `main` branch." When Nora runs `git checkout option/card-layout`, Git simply changes the text in that HEAD file to point to her new branch reference. -You can also manually edit this file, but again a safer command exists to do so: `git symbolic-ref`. -You can read the value of your HEAD via this command: +#### Tags: Permanent Pointers +tag::concept[] -[source,console] ----- -$ git symbolic-ref HEAD -refs/heads/master ----- +(((tags, internals))) +Tags work exactly like branches, but they live in `.git/refs/tags/` and they never move. When Nora created her `v0.1-concept` tag back in Chapter 2, Git just created a file that points to that specific research milestone forever. -You can also set the value of HEAD using the same command: +#### Remotes: The Team's State +tag::concept[] -[source,console] ----- -$ git symbolic-ref HEAD refs/heads/test -$ cat .git/HEAD -ref: refs/heads/test ----- - -You can't set a symbolic reference outside of the refs style: - -[source,console] ----- -$ git symbolic-ref HEAD test -fatal: Refusing to point HEAD outside of refs/ ----- - -==== Tags - -We just finished discussing Git's three main object types (_blobs_, _trees_ and _commits_), but there is a fourth. -The _tag_ object is very much like a commit object -- it contains a tagger, a date, a message, and a pointer. -The main difference is that a tag object generally points to a commit rather than a tree. -It's like a branch reference, but it never moves -- it always points to the same commit but gives it a friendlier name. - -As discussed in <<ch02-git-basics-chapter#ch02-git-basics-chapter>>, there are two types of tags: annotated and lightweight. -You can make a lightweight tag by running something like this: - -[source,console] ----- -$ git update-ref refs/tags/v1.0 cac0cab538b970a37ea1e769cbbde608743bc96d ----- - -That is all a lightweight tag is -- a reference that never moves. -An annotated tag is more complex, however. -If you create an annotated tag, Git creates a tag object and then writes a reference to point to it rather than directly to the commit. -You can see this by creating an annotated tag (using the `-a` option): - -[source,console] ----- -$ git tag -a v1.1 1a410efbd13591db07496601ebc7a059dd55cfe9 -m 'Test tag' ----- - -Here's the object SHA-1 value it created: - -[source,console] ----- -$ cat .git/refs/tags/v1.1 -9585191f37f7b0fb9444f35a9bf50de191beadc2 ----- - -Now, run `git cat-file -p` on that SHA-1 value: - -[source,console] ----- -$ git cat-file -p 9585191f37f7b0fb9444f35a9bf50de191beadc2 -object 1a410efbd13591db07496601ebc7a059dd55cfe9 -type commit -tag v1.1 -tagger Scott Chacon <schacon@gmail.com> Sat May 23 16:48:58 2009 -0700 - -Test tag ----- - -Notice that the object entry points to the commit SHA-1 value that you tagged. -Also notice that it doesn't need to point to a commit; you can tag any Git object. -In the Git source code, for example, the maintainer has added their GPG public key as a blob object and then tagged it. -You can view the public key by running this in a clone of the Git repository: - -[source,console] ----- -$ git cat-file blob junio-gpg-pub ----- - -The Linux kernel repository also has a non-commit-pointing tag object -- the first tag created points to the initial tree of the import of the source code. - -==== Remotes - -The third type of reference that you'll see is a remote reference. -If you add a remote and push to it, Git stores the value you last pushed to that remote for each branch in the `refs/remotes` directory. -For instance, you can add a remote called `origin` and push your `master` branch to it: - -[source,console] ----- -$ git remote add origin git@github.com:schacon/simplegit-progit.git -$ git push origin master -Counting objects: 11, done. -Compressing objects: 100% (5/5), done. -Writing objects: 100% (7/7), 716 bytes, done. -Total 7 (delta 2), reused 4 (delta 1) -To git@github.com:schacon/simplegit-progit.git - a11bef0..ca82a6d master -> master ----- - -Then, you can see what the `master` branch on the `origin` remote was the last time you communicated with the server, by checking the `refs/remotes/origin/master` file: - -[source,console] ----- -$ cat .git/refs/remotes/origin/master -ca82a6dff817ec66f44342007202690a93763949 ----- +(((references, remote))) +When Nora collaborates with Sam and Priya on GitHub, Git keeps track of where the server's branches are using **Remote References** in `.git/refs/remotes/origin/`. These are her "bookmarks" of the team's shared progress. -Remote references differ from branches (`refs/heads` references) mainly in that they're considered read-only. -You can `git checkout` to one, but Git won't symbolically reference HEAD to one, so you'll never update it with a `commit` command. -Git manages them as bookmarks to the last known state of where those branches were on those servers. +By understanding References, Nora can see that Git isn't a "magic box"—it’s a transparent system of pointers and content that she can navigate and understand at any time. diff --git a/book/A-git-in-other-environments/sections/bash.asc b/book/A-git-in-other-environments/sections/bash.asc index 629d2945c..eb46261f4 100644 --- a/book/A-git-in-other-environments/sections/bash.asc +++ b/book/A-git-in-other-environments/sections/bash.asc @@ -1,43 +1,18 @@ === Git in Bash +tag::config[] -(((bash)))(((tab completion, bash)))(((shell prompts, bash))) -If you're a Bash user, you can tap into some of your shell's features to make your experience with Git a lot friendlier. -Git actually ships with plugins for several shells, but it's not turned on by default. +(((Bash)))(((Shell, Bash))) +For "power designers" like Nora who use the command line daily, Bash (the default shell on many systems) can be customized to make Git much easier to use. -First, you need to get a copy of the completions file from the source code of the Git release you're using. -Check your version by typing `git version`, then use `git checkout tags/vX.Y.Z`, where `vX.Y.Z` corresponds to the version of Git you are using. -Copy the `contrib/completion/git-completion.bash` file somewhere handy, like your home directory, and add this to your `.bashrc`: +#### Command Completion +By installing the Git Bash completion script, Nora can just type `git che` and hit the **Tab** key, and Bash will automatically fill in `checkout`. This works for branch names and tags too! -[source,console] ----- -. ~/git-completion.bash ----- - -Once that's done, change your directory to a Git repository, and type: +#### The Prompt +Nora also likes to see which branch she is on directly in her prompt. She can add a few lines to her `~/.bashrc` file to show the current branch name and a color-coded indicator if she has uncommitted changes. -[source,console] +[source,bash] ---- -$ git chec<tab> +# Example Bash prompt with Git branch +export PS1="[\u@\h \W\$(__git_ps1 \" (%s)\")]\$ " ---- - -…and Bash will auto-complete to `git checkout`. -This works with all of Git's subcommands, command-line parameters, and remotes and ref names where appropriate. - -It's also useful to customize your prompt to show information about the current directory's Git repository. -This can be as simple or complex as you want, but there are generally a few key pieces of information that most people want, like the current branch, and the status of the working directory. -To add these to your prompt, just copy the `contrib/completion/git-prompt.sh` file from Git's source repository to your home directory, add something like this to your `.bashrc`: - -[source,console] ----- -. ~/git-prompt.sh -export GIT_PS1_SHOWDIRTYSTATE=1 -export PS1='\w$(__git_ps1 " (%s)")\$ ' ----- - -The `\w` means print the current working directory, the `\$` prints the `$` part of the prompt, and `__git_ps1 " (%s)"` calls the function provided by `git-prompt.sh` with a formatting argument. -Now your bash prompt will look like this when you're anywhere inside a Git-controlled project: - -.Customized `bash` prompt -image::images/git-bash.png[Customized `bash` prompt] - -Both of these scripts come with helpful documentation; take a look at the contents of `git-completion.bash` and `git-prompt.sh` for more information. +Now her prompt looks like this: `[nora@macbook research (main)]$`. This prevents her from ever accidentally committing to the wrong branch. diff --git a/book/A-git-in-other-environments/sections/guis.asc b/book/A-git-in-other-environments/sections/guis.asc index 3c2b62903..794b77cc5 100644 --- a/book/A-git-in-other-environments/sections/guis.asc +++ b/book/A-git-in-other-environments/sections/guis.asc @@ -1,151 +1,40 @@ === Graphical Interfaces +tag::concept[] (((GUIs)))(((Graphical tools))) -Git's native environment is in the terminal. -New features show up there first, and only at the command line is the full power of Git completely at your disposal. -But plain text isn't the best choice for all tasks; sometimes a visual representation is what you need, and some users are much more comfortable with a point-and-click interface. +While the terminal is Git’s native environment and where new features appear first, it isn't always the best choice for every task or every designer. Sometimes a visual representation of your history or a simple point-and-click interface for staging changes is exactly what you need. -It's important to note that different interfaces are tailored for different workflows. -Some clients expose only a carefully curated subset of Git functionality, in order to support a specific way of working that the author considers effective. -When viewed in this light, none of these tools can be called "`better`" than any of the others, they're simply more fit for their intended purpose. -Also note that there's nothing these graphical clients can do that the command-line client can't; the command-line is still where you'll have the most power and control when working with your repositories. +At SketchSpark, the team uses a mix of tools. Nora (UX Lead) handles most things in the terminal, but Priya (Illustrator) and Sam (UI Designer) often reach for graphical tools to manage their assets. -==== `gitk` and `git-gui` +#### GitHub Desktop +tag::procedure[] -(((git commands, gitk)))(((git commands, gui)))(((gitk))) -When you install Git, you also get its visual tools, `gitk` and `git-gui`. +(((GitHub Desktop))) +GitHub Desktop is the primary visual client for the team. It is designed to simplify the "GitHub Flow" and focuses on the most common tasks: cloning, branching, committing, and syncing. -`gitk` is a graphical history viewer. -Think of it like a powerful GUI shell over `git log` and `git grep`. -This is the tool to use when you're trying to find something that happened in the past, or visualize your project's history. +.GitHub Desktop interface +image::images/github_mac.png[GitHub Desktop] -Gitk is easiest to invoke from the command-line. -Just `cd` into a Git repository, and type: +**Key Features for Designers:** +* **Visual Diffing:** Just like the GitHub website, the desktop app allows you to see visual changes in PNGs and other images. +* **Simple Syncing:** Instead of remembering `fetch`, `pull`, and `push`, you just click the **Sync** button. It handles the network dance for you. +* **Easy Staging:** You can click checkboxes next to modified files to stage them, making it easy to create atomic commits without typing filenames. -[source,console] ----- -$ gitk [git log options] ----- - -Gitk accepts many command-line options, most of which are passed through to the underlying `git log` action. -Probably one of the most useful is the `--all` flag, which tells `gitk` to show commits reachable from _any_ ref, not just HEAD. -Gitk's interface looks like this: +GitHub Desktop is "evergreen"—it updates itself in the background and includes its own bundled version of Git, so Priya never has to worry about manual installations. -.The `gitk` history viewer -image::images/gitk.png[The `gitk` history viewer] +#### Gitk and Git-GUI +tag::reference[] -On the top is something that looks a bit like the output of `git log --graph`; each dot represents a commit, the lines represent parent relationships, and refs are shown as colored boxes. -The yellow dot represents HEAD, and the red dot represents changes that are yet to become a commit. -At the bottom is a view of the selected commit; the comments and patch on the left, and a summary view on the right. -In between is a collection of controls used for searching history. +(((gitk)))(((git gui))) +If you’ve installed Git, you already have two simple visual tools: `gitk` (for viewing history) and `git-gui` (for crafting commits). They are more task-oriented and less polished than GitHub Desktop, but they are available on every system where Git is installed. -`git-gui`, on the other hand, is primarily a tool for crafting commits. -It, too, is easiest to invoke from the command line: - -[source,console] +To see a graphical view of your project's branches and merges, Nora often runs: +[source,bash] ---- -$ git gui +$ gitk --all ---- -And it looks something like this: - -.The `git-gui` commit tool -image::images/git-gui.png[The `git-gui` commit tool] - -On the left is the index; unstaged changes are on top, staged changes on the bottom. -You can move entire files between the two states by clicking on their icons, or you can select a file for viewing by clicking on its name. - -At top right is the diff view, which shows the changes for the currently-selected file. -You can stage individual hunks (or individual lines) by right-clicking in this area. - -At the bottom right is the message and action area. -Type your message into the text box and click "`Commit`" to do something similar to `git commit`. -You can also choose to amend the last commit by choosing the "`Amend`" radio button, which will update the "`Staged Changes`" area with the contents of the last commit. -Then you can simply stage or unstage some changes, alter the commit message, and click "`Commit`" again to replace the old commit with a new one. - -`gitk` and `git-gui` are examples of task-oriented tools. -Each of them is tailored for a specific purpose (viewing history and creating commits, respectively), and omit the features not necessary for that task. - -==== GitHub for macOS and Windows - -(((GitHub for macOS)))(((GitHub for Windows))) -GitHub has created two workflow-oriented Git clients: one for Windows, and one for macOS. -These clients are a good example of workflow-oriented tools – rather than expose _all_ of Git's functionality, they instead focus on a curated set of commonly-used features that work well together. -They look like this: - -.GitHub for macOS -image::images/github_mac.png[GitHub for macOS] - -.GitHub for Windows -image::images/github_win.png[GitHub for Windows] - -They are designed to look and work very much alike, so we'll treat them like a single product in this chapter. -We won't be doing a detailed rundown of these tools (they have their own documentation), but a quick tour of the "`changes`" view (which is where you'll spend most of your time) is in order. - -* On the left is the list of repositories the client is tracking; you can add a repository (either by cloning or attaching locally) by clicking the "`+`" icon at the top of this area. -* In the center is a commit-input area, which lets you input a commit message, and select which files should be included. - On Windows, the commit history is displayed directly below this; on macOS, it's on a separate tab. -* On the right is a diff view, which shows what's changed in your working directory, or which changes were included in the selected commit. -* The last thing to notice is the "`Sync`" button at the top-right, which is the primary way you interact over the network. - -[NOTE] -==== -You don't need a GitHub account to use these tools. -While they're designed to highlight GitHub's service and recommended workflow, they will happily work with any repository, and do network operations with any Git host. -==== - -===== Installation - -GitHub for Windows and macOS can be downloaded from https://desktop.github.com/[^]. -When the applications are first run, they walk you through all the first-time Git setup, such as configuring your name and email address, and both set up sane defaults for many common configuration options, such as credential caches and CRLF behavior. - -Both are "`evergreen`" – updates are downloaded and installed in the background while the applications are open. -This helpfully includes a bundled version of Git, which means you probably won't have to worry about manually updating it again. -On Windows, the client includes a shortcut to launch PowerShell with Posh-git, which we'll talk more about later in this chapter. - -The next step is to give the tool some repositories to work with. -The client shows you a list of the repositories you have access to on GitHub, and can clone them in one step. -If you already have a local repository, just drag its directory from the Finder or Windows Explorer into the GitHub client window, and it will be included in the list of repositories on the left. - -===== Recommended Workflow - -Once it's installed and configured, you can use the GitHub client for many common Git tasks. -The intended workflow for this tool is sometimes called the "`GitHub Flow.`" -We cover this in more detail in <<ch06-github#ch06-github_flow>>, but the general gist is that (a) you'll be committing to a branch, and (b) you'll be syncing up with a remote repository fairly regularly. - -Branch management is one of the areas where the two tools diverge. -On macOS, there's a button at the top of the window for creating a new branch: - -."`Create Branch`" button on macOS -image::images/branch_widget_mac.png[“Create Branch” button on macOS] - -On Windows, this is done by typing the new branch's name in the branch-switching widget: - -.Creating a branch on Windows -image::images/branch_widget_win.png[Creating a branch on Windows] - -Once your branch is created, making new commits is fairly straightforward. -Make some changes in your working directory, and when you switch to the GitHub client window, it will show you which files changed. -Enter a commit message, select the files you'd like to include, and click the "`Commit`" button (ctrl-enter or ⌘-enter). - -The main way you interact with other repositories over the network is through the "`Sync`" feature. -Git internally has separate operations for pushing, fetching, merging, and rebasing, but the GitHub clients collapse all of these into one multi-step feature. -Here's what happens when you click the Sync button: - -. `git pull --rebase`. - If this fails because of a merge conflict, fall back to `git pull --no-rebase`. -. `git push`. - -This is the most common sequence of network commands when working in this style, so squashing them into one command saves a lot of time. - -===== Summary - -These tools are very well-suited for the workflow they're designed for. -Developers and non-developers alike can be collaborating on a project within minutes, and many of the best practices for this kind of workflow are baked into the tools. -However, if your workflow is different, or you want more control over how and when network operations are done, we recommend you use another client or the command line. - -==== Other GUIs +#### Other GUI Options +tag::reference[] -There are a number of other graphical Git clients, and they run the gamut from specialized, single-purpose tools all the way to apps that try to expose everything Git can do. -The official Git website has a curated list of the most popular clients at https://git-scm.com/downloads/guis[^]. -A more comprehensive list is available on the Git wiki site, at https://archive.kernel.org/oldwiki/git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools.html#Graphical_Interfaces[^]. +There are dozens of other Git clients, ranging from the powerful (Sourcetree, GitKraken) to the minimal. If GitHub Desktop doesn't fit your workflow, the official Git website maintains a curated list at https://git-scm.com/downloads/guis[^]. diff --git a/book/A-git-in-other-environments/sections/jetbrainsides.asc b/book/A-git-in-other-environments/sections/jetbrainsides.asc index 1def4a3ed..c13648e44 100644 --- a/book/A-git-in-other-environments/sections/jetbrainsides.asc +++ b/book/A-git-in-other-environments/sections/jetbrainsides.asc @@ -1,11 +1,17 @@ -=== Git in IntelliJ / PyCharm / WebStorm / PhpStorm / RubyMine +=== Git in IntelliJ / PyCharm / WebStorm +tag::concept[] (((JetBrains))) -JetBrains IDEs (such as IntelliJ IDEA, PyCharm, WebStorm, PhpStorm, RubyMine, and others) ship with a Git Integration plugin. -It provides a dedicated view in the IDE to work with Git and GitHub Pull Requests. +For Kai, the team’s Frontend and ML Engineer, Git is integrated into his professional development environment. JetBrains IDEs (like IntelliJ, WebStorm, and PyCharm) ship with powerful Git plugins that manage his complex code and model pipeline repos. -.Version Control ToolWindow in JetBrains IDEs -image::images/jb.png[Version Control ToolWindow in JetBrains IDEs] +#### Visual Integration +tag::procedure[] -The integration relies on the command-line Git client, and requires one to be installed. -The official documentation is available at https://www.jetbrains.com/help/idea/using-git-integration.html[^]. +The JetBrains integration provides a dedicated **Version Control Tool Window**. This allows Kai to see a high-fidelity visual graph of all branches and commits—much more detailed than the standard `git log --graph`. + +He can also use "Changelists" to organize his local work into separate buckets before committing, which is useful when he's juggling multiple performance tweaks to the SketchSpark model. + +.Version Control window in JetBrains +image::images/jb.png[JetBrains Git Integration] + +Like VS Code, these IDEs rely on the command-line Git client, but they add a professional management layer on top of it. diff --git a/book/A-git-in-other-environments/sections/visualstudiocode.asc b/book/A-git-in-other-environments/sections/visualstudiocode.asc index 7a646c3b5..77f401cd2 100644 --- a/book/A-git-in-other-environments/sections/visualstudiocode.asc +++ b/book/A-git-in-other-environments/sections/visualstudiocode.asc @@ -1,22 +1,21 @@ === Git in Visual Studio Code +tag::concept[] (((Visual Studio Code))) -Visual Studio Code has Git support built in. -You will need to have Git version 2.0.0 (or newer) installed. +Visual Studio Code (VS Code) is a popular choice for designers who also work with design tokens, CSS, or documentation. For Sam, the UI designer at SketchSpark, VS Code isn't just an editor—it’s where he manages his design-to-code workflow. -The main features are: +#### Built-in Support +tag::procedure[] -* See the diff of the file you are editing in the gutter. -* The Git Status Bar (lower left) shows the current branch, dirty indicators, incoming and outgoing commits. -* You can do the most common git operations from within the editor: -** Initialize a repository. -** Clone a repository. -** Create branches and tags. -** Stage and commit changes. -** Push/pull/sync with a remote branch. -** Resolve merge conflicts. -** View diffs. -* With an extension, you can also handle GitHub Pull Requests: - https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github[^]. +VS Code has excellent Git support built in. If Sam opens the SketchSpark repo in VS Code, he gets several powerful features: -The official documentation can be found here: https://code.visualstudio.com/docs/sourcecontrol/overview[^]. +* **Gutter Diffs:** As Sam edits `design-tokens.json`, he sees small color-coded indicators in the left margin (the "gutter") showing exactly which lines he has added, modified, or deleted. +* **Source Control View:** A dedicated sidebar shows all pending changes. Sam can stage individual files or even individual lines of code by clicking the **+** icon. +* **Status Bar:** At a glance, Sam can see which branch he is on, whether he has unpushed commits, and if there are updates on the server. + +#### GitHub Integration +tag::procedure[] + +By installing the **GitHub Pull Requests and Issues** extension, Sam can handle the entire "GitHub Flow" inside his editor. He can open PRs, read Nora's feedback, and respond to comments without ever switching to a web browser. + +This deep integration makes Git feel like a natural extension of the design process rather than a separate chore. diff --git a/book/A-git-in-other-environments/sections/zsh.asc b/book/A-git-in-other-environments/sections/zsh.asc index c0578a95c..6668ba47d 100644 --- a/book/A-git-in-other-environments/sections/zsh.asc +++ b/book/A-git-in-other-environments/sections/zsh.asc @@ -1,55 +1,18 @@ === Git in Zsh +tag::config[] -(((zsh)))(((tab completion, zsh)))(((shell prompts, zsh))) -Zsh also ships with a tab-completion library for Git. -To use it, simply run `autoload -Uz compinit && compinit` in your `.zshrc`. -Zsh's interface is a bit more powerful than Bash's: +(((Zsh)))(((Shell, Zsh))) +Zsh (the default shell on modern macOS) also provides excellent Git integration. -[source,console] ----- -$ git che<tab> -check-attr -- display gitattributes information -check-ref-format -- ensure that a reference name is well formed -checkout -- checkout branch or paths to working tree -checkout-index -- copy files from index to working directory -cherry -- find commits not merged upstream -cherry-pick -- apply changes introduced by some existing commits ----- - -Ambiguous tab-completions aren't just listed; they have helpful descriptions, and you can graphically navigate the list by repeatedly hitting tab. -This works with Git commands, their arguments, and names of things inside the repository (like refs and remotes), as well as filenames and all the other things Zsh knows how to tab-complete. +#### Command Completion +Zsh’s tab-completion is even more powerful than Bash’s. It can show you a list of available branch names and their most recent commit message as you type. -Zsh ships with a framework for getting information from version control systems, called `vcs_info`. -To include the branch name in the prompt on the right side, add these lines to your `~/.zshrc` file: +#### The Prompt +Like Bash, Nora can customize her Zsh prompt (often using a framework like **Oh My Zsh**) to show a clear visual indicator of her repo's status. -[source,console] +[source,bash] ---- -autoload -Uz vcs_info -precmd_vcs_info() { vcs_info } -precmd_functions+=( precmd_vcs_info ) -setopt prompt_subst -RPROMPT='${vcs_info_msg_0_}' -# PROMPT='${vcs_info_msg_0_}%# ' -zstyle ':vcs_info:git:*' formats '%b' +# Example Oh My Zsh theme showing Git status +PROMPT='%~ %{$fg[blue]%}$(git_prompt_info)%{$reset_color%}%# ' ---- - -This results in a display of the current branch on the right-hand side of the terminal window, whenever your shell is inside a Git repository. -The left side is supported as well, of course; just uncomment the assignment to `PROMPT`. -It looks a bit like this: - -.Customized `zsh` prompt -image::images/zsh-prompt.png[Customized `zsh` prompt] - -For more information on `vcs_info`, check out its documentation in the `zshcontrib(1)` manual page, or online at https://zsh.sourceforge.io/Doc/Release/User-Contributions.html#Version-Control-Information[^]. - -Instead of `vcs_info`, you might prefer the prompt customization script that ships with Git, called `git-prompt.sh`; see https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh[^] for details. -`git-prompt.sh` is compatible with both Bash and Zsh. - -Zsh is powerful enough that there are entire frameworks dedicated to making it better. -One of them is called "oh-my-zsh", and it can be found at https://github.com/ohmyzsh/ohmyzsh[^]. -oh-my-zsh's plugin system comes with powerful Git tab-completion, and it has a variety of prompt "themes", many of which display version-control data. -<<oh_my_zsh_git>> is just one example of what can be done with this system. - -[[oh_my_zsh_git]] -.An example of an oh-my-zsh theme -image::images/zsh-oh-my.png[An example of an oh-my-zsh theme] +This might show a green checkmark if her repo is clean, or a red X if she has modified files. It’s a constant "at-a-glance" status report for her creative environment. diff --git a/book/B-embedding-git/sections/command-line.asc b/book/B-embedding-git/sections/command-line.asc index 01d536913..66d350c0f 100644 --- a/book/B-embedding-git/sections/command-line.asc +++ b/book/B-embedding-git/sections/command-line.asc @@ -1,16 +1,17 @@ === Command-line Git +tag::procedure[] -One option is to spawn a shell process and use the Git command-line tool to do the work. -This has the benefit of being canonical, and all of Git's features are supported. -This also happens to be fairly easy, as most runtime environments have a relatively simple facility for invoking a process with command-line arguments. -However, this approach does have some downsides. +The simplest way to integrate Git is to call the `git` command-line tool directly from your scripts. This is how many "Design-Ops" automations start. -One is that all the output is in plain text. -This means that you'll have to parse Git's occasionally-changing output format to read progress and result information, which can be inefficient and error-prone. +For example, Nora could write a small Bash script that batch-exports every Figma frame as a PNG and then automatically runs `git add` and `git commit` on them. -Another is the lack of error recovery. -If a repository is corrupted somehow, or the user has a malformed configuration value, Git will simply refuse to perform many operations. +**The Pros:** +* **Complete:** You have access to every single feature Git offers. +* **Easy:** Almost every programming language (Python, Node.js, Ruby) makes it easy to run a shell command. -Yet another is process management. -Git requires you to maintain a shell environment on a separate process, which can add unwanted complexity. -Trying to coordinate many of these processes (especially when potentially accessing the same repository from several processes) can be quite a challenge. +**The Cons:** +* **Plain Text:** Git’s output is designed for humans, not machines. Your script has to "parse" (interpret) the text output, which can be brittle if Git updates its formatting. +* **Performance:** Spawning a new process for every command can be slow if you're doing thousands of operations. +* **Error Handling:** It’s harder to recover gracefully from a "corrupt repository" or a network failure when you're just calling a shell command. + +For simple one-off tasks, the command line is great. But for a professional application like SketchSpark, you’ll want something faster and more robust. diff --git a/book/B-embedding-git/sections/introduction.asc b/book/B-embedding-git/sections/introduction.asc new file mode 100644 index 000000000..558d5eb8e --- /dev/null +++ b/book/B-embedding-git/sections/introduction.asc @@ -0,0 +1,10 @@ +[[B-embedding-git-in-your-applications]] +[appendix] +== Embedding Git in your Applications +tag::concept[] + +If you are building a tool for designers—like the SketchSpark app—chances are good that you need to handle versions, parallel explorations, and team synchronization. Instead of reinventing the wheel, you can use Git as your application's "versioning engine." + +Many modern design tools (like Figma, Abstract, or Kactus) use Git or Git-like models under the hood. In this appendix, we’ll look at the technical ways you can integrate Git directly into your own software, from simple command-line automation to embedding high-performance libraries like **Libgit2**. + +Whether you're building a custom internal design-ops dashboard for Nora’s team or a new creative suite, understanding how to "embed" Git will allow you to focus on your UI while Git handles the complex "time machine" logic. diff --git a/book/B-embedding-git/sections/libgit2.asc b/book/B-embedding-git/sections/libgit2.asc index 2e006fdc0..1a825bee1 100644 --- a/book/B-embedding-git/sections/libgit2.asc +++ b/book/B-embedding-git/sections/libgit2.asc @@ -1,237 +1,45 @@ === Libgit2 +tag::concept[] -(((libgit2)))((("C"))) -Another option at your disposal is to use Libgit2. -Libgit2 is a dependency-free implementation of Git, with a focus on having a nice API for use within other programs. -You can find it at https://libgit2.org[^]. +(((libgit2))) +If you’re building a professional-grade design tool, you need more than shell scripts. You need **Libgit2**—a portable, pure C implementation of the Git core that can be embedded directly into your software. It is the engine behind many modern design platforms (like Abstract) and IDEs. -First, let's take a look at what the C API looks like. -Here's a whirlwind tour: +#### Why Use a Library? +Using a library like Libgit2 allows your application to interact with a Git repository directly in memory. This is significantly faster and more reliable than calling the command line. It also provides a structured API, so you get real data objects (Commits, Trees, Blobs) instead of plain text to parse. + +#### Whirlwind Tour (C API) +Here is what it looks like to open the SketchSpark repo and get the latest design checkpoint message using Libgit2: [source,c] ---- -// Open a repository +// Open the SketchSpark repository git_repository *repo; -int error = git_repository_open(&repo, "/path/to/repository"); +int error = git_repository_open(&repo, "/path/to/sketchspark"); -// Dereference HEAD to a commit +// Point to the latest checkpoint (HEAD) git_object *head_commit; error = git_revparse_single(&head_commit, repo, "HEAD^{commit}"); git_commit *commit = (git_commit*)head_commit; -// Print some of the commit's properties +// Print the design decision message printf("%s", git_commit_message(commit)); -const git_signature *author = git_commit_author(commit); -printf("%s <%s>\n", author->name, author->email); -const git_oid *tree_id = git_commit_tree_id(commit); // Cleanup git_commit_free(commit); git_repository_free(repo); ---- -The first couple of lines open a Git repository. -The `git_repository` type represents a handle to a repository with a cache in memory. -This is the simplest method, for when you know the exact path to a repository's working directory or `.git` folder. -There's also the `git_repository_open_ext` which includes options for searching, `git_clone` and friends for making a local clone of a remote repository, and `git_repository_init` for creating an entirely new repository. - -The second chunk of code uses rev-parse syntax (see <<ch07-git-tools#_branch_references>> for more on this) to get the commit that HEAD eventually points to. -The type returned is a `git_object` pointer, which represents something that exists in the Git object database for a repository. -`git_object` is actually a "`parent`" type for several different kinds of objects; the memory layout for each of the "`child`" types is the same as for `git_object`, so you can safely cast to the right one. -In this case, `git_object_type(commit)` would return `GIT_OBJ_COMMIT`, so it's safe to cast to a `git_commit` pointer. - -The next chunk shows how to access the commit's properties. -The last line here uses a `git_oid` type; this is Libgit2's representation for a SHA-1 hash. - -From this sample, a couple of patterns have started to emerge: - -* If you declare a pointer and pass a reference to it into a Libgit2 call, that call will probably return an integer error code. - A `0` value indicates success; anything less is an error. -* If Libgit2 populates a pointer for you, you're responsible for freeing it. -* If Libgit2 returns a `const` pointer from a call, you don't have to free it, but it will become invalid when the object it belongs to is freed. -* Writing C is a bit painful. - -(((Ruby))) -That last one means it isn't very probable that you'll be writing C when using Libgit2. -Fortunately, there are a number of language-specific bindings available that make it fairly easy to work with Git repositories from your specific language and environment. -Let's take a look at the above example written using the Ruby bindings for Libgit2, which are named Rugged, and can be found at https://github.com/libgit2/rugged[^]. +#### Ruby Bindings (Rugged) +Writing C can be tedious. Fortunately, Libgit2 has bindings for almost every major language. For a Design-Ops engineer using Ruby, the **Rugged** gem makes the same task much cleaner: [source,ruby] ---- -repo = Rugged::Repository.new('path/to/repository') +repo = Rugged::Repository.new('path/to/sketchspark') commit = repo.head.target puts commit.message -puts "#{commit.author[:name]} <#{commit.author[:email]}>" -tree = commit.tree ----- - -As you can see, the code is much less cluttered. -Firstly, Rugged uses exceptions; it can raise things like `ConfigError` or `ObjectError` to signal error conditions. -Secondly, there's no explicit freeing of resources, since Ruby is garbage-collected. -Let's take a look at a slightly more complicated example: crafting a commit from scratch - -[source,ruby] ----- -blob_id = repo.write("Blob contents", :blob) # <1> - -index = repo.index -index.read_tree(repo.head.target.tree) -index.add(:path => 'newfile.txt', :oid => blob_id) # <2> - -sig = { - :email => "bob@example.com", - :name => "Bob User", - :time => Time.now, -} - -commit_id = Rugged::Commit.create(repo, - :tree => index.write_tree(repo), # <3> - :author => sig, - :committer => sig, # <4> - :message => "Add newfile.txt", # <5> - :parents => repo.empty? ? [] : [ repo.head.target ].compact, # <6> - :update_ref => 'HEAD', # <7> -) -commit = repo.lookup(commit_id) # <8> ----- - -<1> Create a new blob, which contains the contents of a new file. -<2> Populate the index with the head commit's tree, and add the new file at the path `newfile.txt`. -<3> This creates a new tree in the ODB, and uses it for the new commit. -<4> We use the same signature for both the author and committer fields. -<5> The commit message. -<6> When creating a commit, you have to specify the new commit's parents. - This uses the tip of HEAD for the single parent. -<7> Rugged (and Libgit2) can optionally update a reference when making a commit. -<8> The return value is the SHA-1 hash of a new commit object, which you can then use to get a `Commit` object. - -The Ruby code is nice and clean, but since Libgit2 is doing the heavy lifting, this code will run pretty fast, too. -If you're not a rubyist, we touch on some other bindings in <<_libgit2_bindings>>. - -==== Advanced Functionality - -Libgit2 has a couple of capabilities that are outside the scope of core Git. -One example is pluggability: Libgit2 allows you to provide custom "`backends`" for several types of operation, so you can store things in a different way than stock Git does. -Libgit2 allows custom backends for configuration, ref storage, and the object database, among other things. - -Let's take a look at how this works. -The code below is borrowed from the set of backend examples provided by the Libgit2 team (which can be found at https://github.com/libgit2/libgit2-backends[^]). -Here's how a custom backend for the object database is set up: - -[source,c] ----- -git_odb *odb; -int error = git_odb_new(&odb); // <1> - -git_odb_backend *my_backend; -error = git_odb_backend_mine(&my_backend, /*…*/); // <2> - -error = git_odb_add_backend(odb, my_backend, 1); // <3> - -git_repository *repo; -error = git_repository_open(&repo, "some-path"); -error = git_repository_set_odb(repo, odb); // <4> ----- - -_Note that errors are captured, but not handled. We hope your code is better than ours._ - -<1> Initialize an empty object database (ODB) "`frontend,`" which will act as a container for the "`backends`" which are the ones doing the real work. -<2> Initialize a custom ODB backend. -<3> Add the backend to the frontend. -<4> Open a repository, and set it to use our ODB to look up objects. - -But what is this `git_odb_backend_mine` thing? -Well, that's the constructor for your own ODB implementation, and you can do whatever you want in there, so long as you fill in the `git_odb_backend` structure properly. -Here's what it _could_ look like: - -[source,c] ----- -typedef struct { - git_odb_backend parent; - - // Some other stuff - void *custom_context; -} my_backend_struct; - -int git_odb_backend_mine(git_odb_backend **backend_out, /*…*/) -{ - my_backend_struct *backend; - - backend = calloc(1, sizeof (my_backend_struct)); - - backend->custom_context = …; - - backend->parent.read = &my_backend__read; - backend->parent.read_prefix = &my_backend__read_prefix; - backend->parent.read_header = &my_backend__read_header; - // … - - *backend_out = (git_odb_backend *) backend; - - return GIT_SUCCESS; -} ----- - -The subtlest constraint here is that ``my_backend_struct```'s first member must be a ``git_odb_backend`` structure; this ensures that the memory layout is what the Libgit2 code expects it to be. -The rest of it is arbitrary; this structure can be as large or small as you need it to be. - -The initialization function allocates some memory for the structure, sets up the custom context, and then fills in the members of the `parent` structure that it supports. -Take a look at the `include/git2/sys/odb_backend.h` file in the Libgit2 source for a complete set of call signatures; your particular use case will help determine which of these you'll want to support. - -[[_libgit2_bindings]] -==== Other Bindings - -Libgit2 has bindings for many languages. -Here we show a small example using a few of the more complete bindings packages as of this writing; libraries exist for many other languages, including C++, Go, Node.js, Erlang, and the JVM, all in various stages of maturity. -The official collection of bindings can be found by browsing the repositories at https://github.com/libgit2[^]. -The code we'll write will return the commit message from the commit eventually pointed to by HEAD (sort of like `git log -1`). - -===== LibGit2Sharp - -(((.NET)))(((C#)))(((Mono))) -If you're writing a .NET or Mono application, LibGit2Sharp (https://github.com/libgit2/libgit2sharp[^]) is what you're looking for. -The bindings are written in C#, and great care has been taken to wrap the raw Libgit2 calls with native-feeling CLR APIs. -Here's what our example program looks like: - -[source,csharp] ----- -new Repository(@"C:\path\to\repo").Head.Tip.Message; ----- - -For desktop Windows applications, there's even a NuGet package that will help you get started quickly. - -===== objective-git - -(((Apple)))(((Objective-C)))(((Cocoa))) -If your application is running on an Apple platform, you're likely using Objective-C as your implementation language. -Objective-Git (https://github.com/libgit2/objective-git[^]) is the name of the Libgit2 bindings for that environment. -The example program looks like this: - -[source,objc] ----- -GTRepository *repo = - [[GTRepository alloc] initWithURL:[NSURL fileURLWithPath: @"/path/to/repo"] error:NULL]; -NSString *msg = [[[repo headReferenceWithError:NULL] resolvedTarget] message]; ----- - -Objective-git is fully interoperable with Swift, so don't fear if you've left Objective-C behind. - -===== pygit2 - -(((Python))) -The bindings for Libgit2 in Python are called Pygit2, and can be found at https://www.pygit2.org[^]. -Our example program: - -[source,python] ----- -pygit2.Repository("/path/to/repo") # open repository - .head # get the current branch - .peel(pygit2.Commit) # walk down to the commit - .message # read the message ---- -==== Further Reading +#### Advanced: Pluggable Backends +One of the most powerful features of Libgit2 for design tools is **pluggability**. It allows you to store Git objects in something other than the standard `.git` folder—like a custom database or a cloud-based storage system. This is how some design platforms manage massive asset libraries without cluttering the user's hard drive. -Of course, a full treatment of Libgit2's capabilities is outside the scope of this book. -If you want more information on Libgit2 itself, there's API documentation at https://libgit2.github.com/libgit2[^], and a set of guides at https://libgit2.github.com/docs[^]. -For the other bindings, check the bundled README and tests; there are often small tutorials and pointers to further reading there. +For complete documentation and a full list of language bindings (Python, Node.js, .NET, Swift, and more), visit https://libgit2.org[^]. diff --git a/book/GEMINI.md b/book/GEMINI.md new file mode 100644 index 000000000..6e0222c93 --- /dev/null +++ b/book/GEMINI.md @@ -0,0 +1,30 @@ +# Authoring Context: Pro Git for UX Designers + +This directory contains the AsciiDoc source for the book. When authoring or revising content, strictly adhere to the following guides and conventions. + +## Core Mandates +- **Tone:** Follow the [Voice and Tone Guide](../00-notes/voice-and-tone.md). Be empathetic, visual, and narrative-driven. +- **Consistency:** Adhere to [Cross-Chapter Conventions](../00-notes/conventions.md) for character names, branch names, and milestones. +- **Content Types:** Every sub-section must be tagged with a content type from the [Content Type Lexicon](../00-notes/content-type-lexicon.md). +- **Structure:** Use AsciiDoc. Keep sections modular. Include walkthroughs that reference the sample `sketchspark/` repository. + +## Working with Walkthroughs +- Use the `sketchspark/` directory in the root to verify commands if possible. +- When describing a command, explain the *intent* (Nora's perspective) before showing the syntax. +- Use `[Phase: Component]` prefixes for any example commit messages. + +## Chapter Progress +Refer to `00-notes/storyline.md` to ensure the narrative progression matches the chapter's Git focus. + +## Content Tagging Example +```asciidoc +==== Stage Your Changes +tag::walkthrough[] + +Nora has updated the product brief and is ready to select her changes for the next checkpoint... + +[source,bash] +---- +git add product-brief.md +---- +``` diff --git a/ch01-getting-started.asc b/ch01-getting-started.asc index b5f0d22c2..e0b1828e4 100644 --- a/ch01-getting-started.asc +++ b/ch01-getting-started.asc @@ -1,9 +1,7 @@ [[ch01-getting-started]] == Getting Started -This chapter will be about getting started with Git. -We will begin by explaining some background on version control tools, then move on to how to get Git running on your system and finally how to get it set up to start working with. -At the end of this chapter you should understand why Git is around, why you should use it and you should be all set up to do so. +This chapter is about getting started with Git. We will begin by explaining some background on version control tools—through the eyes of Nora, our UX Lead—then move on to how to get Git running on your system and finally how to get it set up to start working with. At the end of this chapter, you should understand why Git is essential for design projects, why you should use it, and you should be all set up to do so. include::book/01-introduction/sections/about-version-control.asc[] @@ -20,7 +18,6 @@ include::book/01-introduction/sections/first-time-setup.asc[] include::book/01-introduction/sections/help.asc[] === Summary +tag::overview[] -You should have a basic understanding of what Git is and how it's different from any centralized version control systems you may have been using previously. -You should also now have a working version of Git on your system that's set up with your personal identity. -It's now time to learn some Git basics. +You should have a basic understanding of what Git is and how it's different from the manual folder-copying or centralized version control systems you may have been using previously. You should also now have a working version of Git on your system that's set up with your personal identity (Nora UX). It's now time to learn some Git basics and start tracking Nora's project. diff --git a/ch02-git-basics-chapter.asc b/ch02-git-basics-chapter.asc index 08db2548a..091b6cff6 100644 --- a/ch02-git-basics-chapter.asc +++ b/ch02-git-basics-chapter.asc @@ -1,10 +1,17 @@ [[ch02-git-basics-chapter]] == Git Basics -If you can read only one chapter to get going with Git, this is it. -This chapter covers every basic command you need to do the vast majority of the things you'll eventually spend your time doing with Git. -By the end of the chapter, you should be able to configure and initialize a repository, begin and stop tracking files, and stage and commit changes. -We'll also show you how to set up Git to ignore certain files and file patterns, how to undo mistakes quickly and easily, how to browse the history of your project and view changes between commits, and how to push and pull from remote repositories. +If you can read only one chapter to get going with Git, this is it. This chapter covers every basic command you need to do the vast majority of the things you’ll eventually spend your time doing with Git. + +We will follow Nora as she initializes her first repository for the SketchSpark project, begins tracking her research files, and learns the daily rhythm of staging and committing changes. By the end of this chapter, you should be able to: + +* Configure and initialize a repository. +* Begin and stop tracking files (including design assets). +* Stage and commit changes using the team's conventions. +* Set up Git to ignore "junk" files from your design tools. +* Undo mistakes quickly and easily. +* Browse the project's history and trace **design decisions**. +* Work with remote repositories and shared milestones. include::book/02-git-basics/sections/getting-a-repository.asc[] @@ -21,6 +28,8 @@ include::book/02-git-basics/sections/tagging.asc[] include::book/02-git-basics/sections/aliases.asc[] === Summary +tag::overview[] + +At this point, you can do all the basic local Git operations—creating or cloning a repository, making changes, staging and committing those changes, and viewing the history of all the decisions your project has been through. You’ve even tagged your first major milestone: `v0.1-concept`. -At this point, you can do all the basic local Git operations -- creating or cloning a repository, making changes, staging and committing those changes, and viewing the history of all the changes the repository has been through. -Next, we'll cover Git's killer feature: its branching model. +Next, we’ll cover Git’s killer feature: its branching model. This is where Nora and Sam truly unlock the power of parallel exploration. diff --git a/ch03-git-branching.asc b/ch03-git-branching.asc index 60d1a1934..f00a5f391 100644 --- a/ch03-git-branching.asc +++ b/ch03-git-branching.asc @@ -2,15 +2,11 @@ == Git Branching (((branches))) -Nearly every VCS has some form of branching support. -Branching means you diverge from the main line of development and continue to do work without messing with that main line. -In many VCS tools, this is a somewhat expensive process, often requiring you to create a new copy of your source code directory, which can take a long time for large projects. +Nearly every version control system has some form of branching support. Branching means you diverge from the main line of work and continue to do work without messing with that main line. -Some people refer to Git's branching model as its "`killer feature,`" and it certainly sets Git apart in the VCS community. -Why is it so special? -The way Git branches is incredibly lightweight, making branching operations nearly instantaneous, and switching back and forth between branches generally just as fast. -Unlike many other VCSs, Git encourages workflows that branch and merge often, even multiple times in a day. -Understanding and mastering this feature gives you a powerful and unique tool and can entirely change the way that you develop. +Some people refer to Git's branching model as its "killer feature," and it certainly sets Git apart. Why? Because the way Git branches is incredibly lightweight, making branching operations nearly instantaneous, and switching back and forth between branches just as fast. + +Unlike many other systems, Git encourages workflows that branch and merge often, even multiple times in a day. Understanding and mastering this feature gives Nora and Sam at SketchSpark a powerful tool to manage **parallel explorations**, handling everything from layout experiments to critical bug fixes without losing their creative flow. include::book/03-git-branching/sections/nutshell.asc[] @@ -25,8 +21,10 @@ include::book/03-git-branching/sections/remote-branches.asc[] include::book/03-git-branching/sections/rebasing.asc[] === Summary +tag::overview[] + +We've covered basic branching and merging in Git. You should feel comfortable creating and switching to new branches, and merging local branches together to reconcile divergent design ideas. + +You should also be able to share your explorations by pushing them to a shared server (like Nora does for Sam and Priya), working with others on shared branches, and rebasing your local work before it's shared to keep your project's history clean and readable. -We've covered basic branching and merging in Git. -You should feel comfortable creating and switching to new branches, switching between branches and merging local branches together. -You should also be able to share your branches by pushing them to a shared server, working with others on shared branches and rebasing your branches before they are shared. -Next, we'll cover what you'll need to run your own Git repository-hosting server. +Next, we’ll move beyond individual and pair work to cover what you’ll need to set up and manage a Git infrastructure for your entire team. diff --git a/ch04-git-on-the-server.asc b/ch04-git-on-the-server.asc index a867a63c9..9af42b523 100644 --- a/ch04-git-on-the-server.asc +++ b/ch04-git-on-the-server.asc @@ -2,23 +2,11 @@ == Git on the Server (((serving repositories))) -At this point, you should be able to do most of the day-to-day tasks for which you'll be using Git. -However, in order to do any collaboration in Git, you'll need to have a remote Git repository. -Although you can technically push changes to and pull changes from individuals' repositories, doing so is discouraged because you can fairly easily confuse what they're working on if you're not careful. -Furthermore, you want your collaborators to be able to access the repository even if your computer is offline -- having a more reliable common repository is often useful. -Therefore, the preferred method for collaborating with someone is to set up an intermediate repository that you both have access to, and push to and pull from that. +At this point, you should be able to do most of the day-to-day tasks for which you’ll be using Git. However, in order to do any collaboration, you’ll need to have a remote Git repository. -Running a Git server is fairly straightforward. -First, you choose which protocols you want your server to support. -The first section of this chapter will cover the available protocols and the pros and cons of each. -The next sections will explain some typical setups using those protocols and how to get your server running with them. -Last, we'll go over a few hosted options, if you don't mind hosting your code on someone else's server and don't want to go through the hassle of setting up and maintaining your own server. +Although you can technically push changes to and pull changes from a teammate's computer, doing so is discouraged—it’s far too easy to confuse who is working on what. Furthermore, Nora wants Sam and Priya to be able to access the project even if her laptop is closed. Having a reliable, common repository (a "source of truth") is essential for a growing design team. -If you have no interest in running your own server, you can skip to the last section of the chapter to see some options for setting up a hosted account and then move on to the next chapter, where we discuss the various ins and outs of working in a distributed source control environment. - -A remote repository is generally a _bare repository_ -- a Git repository that has no working directory. -Because the repository is only used as a collaboration point, there is no reason to have a snapshot checked out on disk; it's just the Git data. -In the simplest terms, a bare repository is the contents of your project's `.git` directory and nothing else. +In this chapter, we’ll explore how Nora chooses the right infrastructure for SketchSpark. We’ll look at the different protocols Git uses to talk to servers, how to set up a simple "bare" repository for the team, and why a hosted service like GitHub is often the best choice for designers who want to focus on their work rather than server maintenance. include::book/04-git-server/sections/protocols.asc[] @@ -26,23 +14,13 @@ include::book/04-git-server/sections/git-on-a-server.asc[] include::book/04-git-server/sections/generating-ssh-key.asc[] -include::book/04-git-server/sections/setting-up-server.asc[] - -include::book/04-git-server/sections/git-daemon.asc[] - -include::book/04-git-server/sections/smart-http.asc[] - -include::book/04-git-server/sections/gitweb.asc[] - -include::book/04-git-server/sections/gitlab.asc[] - include::book/04-git-server/sections/hosted.asc[] === Summary +tag::overview[] -You have several options to get a remote Git repository up and running so that you can collaborate with others or share your work. +You have several options to get a remote Git repository up and running so that you can collaborate with others or share your work. -Running your own server gives you a lot of control and allows you to run the server within your own firewall, but such a server generally requires a fair amount of your time to set up and maintain. -If you place your data on a hosted server, it's easy to set up and maintain; however, you have to be able to keep your code on someone else's servers, and some organizations don't allow that. +Running your own server gives you total control, but it requires time to set up and maintain. For the SketchSpark team, placing their data on a hosted server is the faster, more reliable path. It allows Nora to set up the project in minutes and gives the team access to powerful collaboration tools like branch protection and pull requests. -It should be fairly straightforward to determine which solution or combination of solutions is appropriate for you and your organization. +Now that the team has a home on the server, it’s time to look at the various ways Nora, Sam, and Priya can actually work together in this distributed environment. diff --git a/ch05-distributed-git.asc b/ch05-distributed-git.asc index 588a2174b..cd7e59bbb 100644 --- a/ch05-distributed-git.asc +++ b/ch05-distributed-git.asc @@ -2,10 +2,9 @@ == Distributed Git (((distributed git))) -Now that you have a remote Git repository set up as a focal point for all the developers to share their code, and you're familiar with basic Git commands in a local workflow, you'll look at how to utilize some of the distributed workflows that Git affords you. +Now that you have a remote Git repository set up as a focal point for all the designers to share their work, and you're familiar with basic Git commands, you’ll look at how to utilize the distributed workflows that Git affords you. -In this chapter, you'll see how to work with Git in a distributed environment as a contributor and an integrator. -That is, you'll learn how to contribute code successfully to a project and make it as easy on you and the project maintainer as possible, and also how to maintain a project successfully with a number of developers contributing. +In this chapter, you’ll see how Nora, Sam, and Priya work together across their separate environments. We’ll explore different collaboration models—from tight-knit team work to managing external contributions via "forks." Whether you are contributing your latest Figma exports or maintaining a massive global design system, you’ll learn how to keep your project organized and its history clean. include::book/05-distributed-git/sections/distributed-workflows.asc[] @@ -14,7 +13,8 @@ include::book/05-distributed-git/sections/contributing.asc[] include::book/05-distributed-git/sections/maintaining.asc[] === Summary +tag::overview[] -You should feel fairly comfortable contributing to a project in Git as well as maintaining your own project or integrating other users' contributions. -Congratulations on being an effective Git developer! -In the next chapter, you'll learn about how to use the largest and most popular Git hosting service, GitHub. +You should now feel comfortable collaborating in a distributed design environment—whether that means pushing directly to your team's repo or contributing to a public project through pull requests. + +Congratulations on becoming an effective distributed designer! In the next chapter, we’ll move from the terminal to the browser and explore the largest and most popular home for design systems in the world: **GitHub**. diff --git a/ch06-github.asc b/ch06-github.asc index e2cd29e7b..7e17be382 100644 --- a/ch06-github.asc +++ b/ch06-github.asc @@ -2,21 +2,9 @@ == GitHub (((GitHub))) -GitHub is the single largest host for Git repositories, and is the central point of collaboration for millions of developers and projects. -A large percentage of all Git repositories are hosted on GitHub, and many open-source projects use it for Git hosting, issue tracking, code review, and other things. -So while it's not a direct part of the Git open source project, there's a good chance that you'll want or need to interact with GitHub at some point while using Git professionally. +GitHub is the largest host for Git repositories and the central point of collaboration for millions of designers, developers, and researchers. Most of the world's major design systems and open-source projects use GitHub for hosting, issue tracking, and collaborative code/UI review. -This chapter is about using GitHub effectively. -We'll cover signing up for and managing an account, creating and using Git repositories, common workflows to contribute to projects and to accept contributions to yours, GitHub's programmatic interface and lots of little tips to make your life easier in general. - -If you are not interested in using GitHub to host your own projects or to collaborate with other projects that are hosted on GitHub, you can safely skip to <<ch07-git-tools#ch07-git-tools>>. - -[WARNING] -.Interfaces Change -==== -It's important to note that like many active websites, the UI elements in these screenshots are bound to change over time. -Hopefully the general idea of what we're trying to accomplish here will still be there, but if you want more up to date versions of these screens, the online versions of this book may have newer screenshots. -==== +In this chapter, we’ll follow Nora as she establishes the SketchSpark organization on GitHub. We’ll cover how Sam and Priya set up their accounts, how the team uses the "GitHub Flow" for design critiques, and how Nora uses GitHub’s administrative tools to protect the project's integrity. Whether you’re contributing to a massive global design system or managing a tight-knit startup team, GitHub is the platform where design collaboration happens. include::book/06-github/sections/1-setting-up-account.asc[] @@ -29,7 +17,8 @@ include::book/06-github/sections/4-managing-organization.asc[] include::book/06-github/sections/5-scripting.asc[] === Summary +tag::overview[] + +Now you’re a GitHub user. You know how to create an account, manage an organization, use the GitHub Flow for collaborative design reviews, and even automate your workflow with webhooks and the API. -Now you're a GitHub user. -You know how to create an account, manage an organization, create and push to repositories, contribute to other people's projects and accept contributions from others. -In the next chapter, you'll learn more powerful tools and tips for dealing with complex situations, which will truly make you a Git master. +By moving the SketchSpark project to GitHub, Nora has created a professional, secure, and transparent environment for her team to do their best work. In the next chapter, we’ll move back to the terminal to look at some of the most powerful "expert-level" tools that will truly make you a master of Git. diff --git a/ch07-git-tools.asc b/ch07-git-tools.asc index 0e7fad551..aaa2086eb 100644 --- a/ch07-git-tools.asc +++ b/ch07-git-tools.asc @@ -1,10 +1,11 @@ [[ch07-git-tools]] == Git Tools -By now, you've learned most of the day-to-day commands and workflows that you need to manage or maintain a Git repository for your source code control. -You've accomplished the basic tasks of tracking and committing files, and you've harnessed the power of the staging area and lightweight topic branching and merging. +By now, you’ve learned most of the day-to-day commands and workflows you need to manage a design project with Git. You’ve harnessed the power of the staging area, topic branching, and collaborative review on GitHub. -Now you'll explore a number of very powerful things that Git can do that you may not necessarily use on a day-to-day basis but that you may need at some point. +Now, we’ll explore a set of "expert-level" tools. These aren't necessarily things Nora and her team use every hour, but they are essential for managing complex design workflows, recovering from mistakes, and keeping the SketchSpark repository professional and organized. + +In this chapter, we’ll look at how to precisely select checkpoints from the past, selectively stage changes "hunk by hunk," handle interruptions with stashing, and even rewrite the project's history to tell a better story. We’ll also demystify the confusing `reset` command and look at powerful ways to search your entire design archive. include::book/07-git-tools/sections/revision-selection.asc[] @@ -12,31 +13,17 @@ include::book/07-git-tools/sections/interactive-staging.asc[] include::book/07-git-tools/sections/stashing-cleaning.asc[] -include::book/07-git-tools/sections/signing.asc[] - include::book/07-git-tools/sections/searching.asc[] include::book/07-git-tools/sections/rewriting-history.asc[] include::book/07-git-tools/sections/reset.asc[] -include::book/07-git-tools/sections/advanced-merging.asc[] - -include::book/07-git-tools/sections/rerere.asc[] - -include::book/07-git-tools/sections/debugging.asc[] - -include::book/07-git-tools/sections/submodules.asc[] - -include::book/07-git-tools/sections/bundling.asc[] - -include::book/07-git-tools/sections/replace.asc[] +=== Summary +tag::overview[] -include::book/07-git-tools/sections/credentials.asc[] +You’ve seen a number of advanced tools that allow you to manipulate your checkpoints and staging area with surgical precision. When you notice an issue, you should now be able to easily figure out what decision introduced it, when, and by whom. -=== Summary +You’ve also learned how to "pause" your creative flow with stashing and how to "curate" your history with rebasing. These tools transform Git from a simple file-tracker into a professional design-ops platform. -You've seen a number of advanced tools that allow you to manipulate your commits and staging area more precisely. -When you notice issues, you should be able to easily figure out what commit introduced them, when, and by whom. -If you want to use subprojects in your project, you've learned how to accommodate those needs. -At this point, you should be able to do most of the things in Git that you'll need on the command line day to day and feel comfortable doing so. +In the next chapter, we’ll look at how Nora can **customize** Git to better handle the unique needs of a design team—from large binary assets to custom diff tools for visual files. diff --git a/ch08-customizing-git.asc b/ch08-customizing-git.asc index 2af938c0a..728aaccef 100644 --- a/ch08-customizing-git.asc +++ b/ch08-customizing-git.asc @@ -1,9 +1,11 @@ [[ch08-customizing-git]] == Customizing Git -So far, we've covered the basics of how Git works and how to use it, and we've introduced a number of tools that Git provides to help you use it easily and efficiently. -In this chapter, we'll see how you can make Git operate in a more customized fashion, by introducing several important configuration settings and the hooks system. -With these tools, it's easy to get Git to work exactly the way you, your company, or your group needs it to. +So far, we’ve covered the basics of how Git works and how to use it collaboratively on GitHub. We’ve introduced the staging area, topic branching, and the "GitHub Flow" for design reviews. + +In this chapter, we’ll see how Nora can make Git operate in a more customized fashion. Just as you customize your Figma workspace or your IDE, you can tune Git to work exactly how your design team needs it to. + +We’ll explore how Nora uses **Configuration** to make the CLI more forgiving, **Attributes** to handle large binary files and visual diffs, and **Hooks** to automate the repetitive parts of design-ops. By the end of this chapter, you’ll be able to transform Git from a generic tool into a specialized platform perfectly suited for the SketchSpark project. include::book/08-customizing-git/sections/config.asc[] @@ -14,7 +16,8 @@ include::book/08-customizing-git/sections/hooks.asc[] include::book/08-customizing-git/sections/policy.asc[] === Summary +tag::overview[] + +We’ve covered the major ways you can customize your Git client and server to best fit your design workflow. You’ve learned how to enforce team conventions with templates, manage massive asset libraries with Git LFS, and automate your manual checks with hooks. -We've covered most of the major ways that you can customize your Git client and server to best fit your workflow and projects. -You've learned about all sorts of configuration settings, file-based attributes, and event hooks, and you've built an example policy-enforcing server. -You should now be able to make Git fit nearly any workflow you can dream up. +You should now be able to make Git fit nearly any design-ops workflow you can dream up. In the next chapter, we’ll look at how Nora manages the "outside world"—using Git to talk to other version control systems and importing legacy projects. diff --git a/ch09-git-and-other-systems.asc b/ch09-git-and-other-systems.asc index af4f22008..c6f72daa2 100644 --- a/ch09-git-and-other-systems.asc +++ b/ch09-git-and-other-systems.asc @@ -1,44 +1,21 @@ [[ch09-git-and-other-systems]] == Git and Other Systems -The world isn't perfect. -Usually, you can't immediately switch every project you come in contact with to Git. -Sometimes you're stuck on a project using another VCS, and wish it was Git. -We'll spend the first part of this chapter learning about ways to use Git as a client when the project you're working on is hosted in a different system. +The world isn't perfect. Usually, you can’t immediately switch every project you come in contact with to Git. Sometimes you’re stuck on a legacy project using another version control system, and wish it was Git. -At some point, you may want to convert your existing project to Git. -The second part of this chapter covers how to migrate your project into Git from several specific systems, as well as a method that will work if no pre-built import tool exists. +In this chapter, we’ll follow Nora as she navigates the "outside world." We’ll look at how she uses Git as a client for her old agency's Subversion (SVN) server, how she performs a professional "one-way" migration to GitHub, and how she even rescues very old projects from a simple directory of dated backups. -=== Git as a Client - -(((Git as a client))) -Git provides such a nice experience for developers that many people have figured out how to use it on their workstation, even if the rest of their team is using an entirely different VCS. -There are a number of these adapters, called "`bridges,`" available. -Here we'll cover the ones you're most likely to run into in the wild. +Whether you're stuck in a corporate environment with "ancient" tools or you're looking to unify your team's history into a single modern repo, these bridging and importing tools will ensure you never have to leave the power and comfort of Git. include::book/09-git-and-other-scms/sections/client-svn.asc[] -include::book/09-git-and-other-scms/sections/client-hg.asc[] - -include::book/09-git-and-other-scms/sections/client-p4.asc[] - -[[_migrating]] -=== Migrating to Git - -(((Migrating to Git))) -If you have an existing codebase in another VCS but you've decided to start using Git, you must migrate your project one way or another. -This section goes over some importers for common systems, and then demonstrates how to develop your own custom importer. -You'll learn how to import data from several of the bigger professionally used SCM systems, because they make up the majority of users who are switching, and because high-quality tools for them are easy to come by. - include::book/09-git-and-other-scms/sections/import-svn.asc[] -include::book/09-git-and-other-scms/sections/import-hg.asc[] - -include::book/09-git-and-other-scms/sections/import-p4.asc[] - include::book/09-git-and-other-scms/sections/import-custom.asc[] === Summary +tag::overview[] + +You should now feel comfortable using Git as a bridge to other systems or importing nearly any existing project into Git without losing your precious design history. -You should feel comfortable using Git as a client for other version-control systems, or importing nearly any existing repository into Git without losing data. -In the next chapter, we'll cover the raw internals of Git so you can craft every single byte, if need be. +Congratulations! You’ve mastered the daily workflows, the team collaboration on GitHub, and the art of importing the past. In the final chapter, we’ll take one last step: peeling back the UI to look at the raw **internals** of Git, so you can understand exactly how every byte of your design is stored. diff --git a/ch10-git-internals.asc b/ch10-git-internals.asc index a82f2fbc5..f48440aa2 100644 --- a/ch10-git-internals.asc +++ b/ch10-git-internals.asc @@ -1,19 +1,11 @@ [[ch10-git-internals]] == Git Internals -You may have skipped to this chapter from a much earlier chapter, or you may have gotten here after sequentially reading the entire book up to this point -- in either case, this is where we'll go over the inner workings and implementation of Git. -We found that understanding this information was fundamentally important to appreciating how useful and powerful Git is, but others have argued to us that it can be confusing and unnecessarily complex for beginners. -Thus, we've made this discussion the last chapter in the book so you could read it early or later in your learning process. -We leave it up to you to decide. +You may have skipped to this chapter from a much earlier chapter, or you may have gotten here after sequentially reading the entire book up to this point—in either case, this is where we peel back the polished "porcelain" UI to look at the raw implementation of Git. -Now that you're here, let's get started. -First, if it isn't yet clear, Git is fundamentally a content-addressable filesystem with a VCS user interface written on top of it. -You'll learn more about what this means in a bit. +Understanding Git's internals is fundamentally important to appreciating how useful and powerful it is. For Nora and the team at SketchSpark, this knowledge is the final piece of the puzzle. It transforms Git from a "magic time machine" into a transparent, predictable filesystem that protects every design decision they’ve ever made. -In the early days of Git (mostly pre 1.5), the user interface was much more complex because it emphasized this filesystem rather than a polished VCS. -In the last few years, the UI has been refined until it's as clean and easy to use as any system out there; however, the stereotype lingers about the early Git UI that was complex and difficult to learn. - -The content-addressable filesystem layer is amazingly cool, so we'll cover that first in this chapter; then, you'll learn about the transport mechanisms and the repository maintenance tasks that you may eventually have to deal with. +In this final chapter, we’ll take a tour of the `.git` directory—the brain of the project. We’ll look at the core objects that store content, the simple references that make branching so fast, and the recovery tools that ensure that in the world of distributed design, **your work is never truly lost.** include::book/10-git-internals/sections/plumbing-porcelain.asc[] @@ -21,21 +13,21 @@ include::book/10-git-internals/sections/objects.asc[] include::book/10-git-internals/sections/refs.asc[] -include::book/10-git-internals/sections/packfiles.asc[] +include::book/10-git-internals/sections/maintenance.asc[] + +=== Summary +tag::overview[] -include::book/10-git-internals/sections/refspec.asc[] +You’ve now seen the inner workings of Git. You understand that Git is fundamentally a content-addressable filesystem with a user-friendly interface built on top of it. You’ve learned how Git stores raw design data as blobs, links them into trees, and checkpoints them as commits. -include::book/10-git-internals/sections/transfer-protocols.asc[] +Understanding these internals should make it easier to understand *why* Git does what it does, and give you the confidence to navigate any complex design-ops situation. We hope you can use your newfound knowledge of Git to implement your own specialized design workflows and feel comfortable using Git in more advanced ways. -include::book/10-git-internals/sections/maintenance.asc[] +### The End of the SketchSpark Journey -include::book/10-git-internals/sections/environment.asc[] +When Nora first lost her research to a cloud sync glitch, she was terrified. She felt that her creative process was fragile and that her work was always one click away from disappearing. -=== Summary +By mastering Git, Nora, Sam, Priya, and Kai have built more than just a rapid prototyping application called SketchSpark. They’ve built a **culture of trust**. They know they can experiment without fear, collaborate across the globe, and trace the history of every pixel and every word. -At this point, you should have a pretty good understanding of what Git does in the background and, to some degree, how it's implemented. -This chapter has covered a number of plumbing commands -- commands that are lower level and simpler than the porcelain commands you've learned about in the rest of the book. -Understanding how Git works at a lower level should make it easier to understand why it's doing what it's doing and also to write your own tools and helper scripts to make your specific workflow work for you. +The story ends where it began, but with a different outcome: Nora opens her project folder, sees her thousand checkpoints, and smiles. She knows that with Git, her work is safe. -Git as a content-addressable filesystem is a very powerful tool that you can easily use as more than just a VCS. -We hope you can use your newfound knowledge of Git internals to implement your own cool application of this technology and feel more comfortable using Git in more advanced ways. +**Happy designing!** diff --git a/sketchspark-author.skill b/sketchspark-author.skill new file mode 100644 index 0000000000000000000000000000000000000000..94b08256c18ca786cb5366b8617daf80c12d29b2 GIT binary patch literal 26332 zcmagFQ;aT7^rhXlZTIQZwr$&|ZQHi-wr$(CZQHhu?>Cb#ll(ImQ^~HXi^{rul2v;z z1!+()7@+^Pj4>*;|M%tp-(Z38fE-OsO&m>ZjZB>ARaKyYK%+{4E#v<y7k5}7V6bOk zARsWb|DG%SC-T2esQ)cu*Y-~-gdGSdAOQ#n^M8ssIommUSX<bd(AgOOAHnGVTQEy& z+7VYgq34j2sw^CNTy)UL%M`KeYNEl~L979-<SLyv0^Aw+Z~gr8;<79hm$l3l^Bade zyL`iLs^+peQlIq@mvtgoMPtLm>16JNuPI+ucDtATwxQ4J+DreIOa8WMk89$1quImt zCtK2YL8eSitvGCLZ46*!<z(1qKDgRS$Kv1S+X9QtnNX{hcQ;du1yyfdHsbSC7ejHB zuWIMYlPtP5wye4A`UWjjI@?oab3{YX`{}OVpm?(lfwxUdkIUqW?G{?D&1#R+qrR4P z(}>ttRpaA?i%>-7#Gs3ZeO2;cON$e-Rwi9qv7d7ZbTYt-;b*cM8a_Q5;&UHZOSL9r z{2nq#>-B7#O>UaRx^8H{^^B_ZY|ICm0JDf;xPyEMQfgae4XC%n3A4p`Go$TARyc=} zdcu`0-M;b(bF2jrtD@dQEWF((HXl;p45)#b9$C(|@IEZ7!qt2%-(@jf50ynJq0c@x zsP{;1MP25&pi?v8=0;i|QAxHbxT|rN>LlGYJ-j4P=`&MA3o`MxcNK1Yqin)>5orH? zP=6d*S3<~v8|~T@@?L|Mr^yp7w$6_qp0Ngf*{(6*i;HB&)jEt~%El;&o@uFr>@*jS zE`ig-b4E)sRrKKW!{t*1jdNB_7he@C1Df45r^^G^^6~z9Ih?K4?RtNk+^#$ryxi>6 zRHmbsDXY&eo=%~qA%=0AEnIK2#h22sW@X)6iCS3^EatT9))HH`aGv90)8nuQ-(MkT z;a13}>w}m<e^cp>JQ0^j%IIUqFEYJCQ3Hk_WVgQBn5+5*5rf88<tT%x1jt!*dpmKX zzBXpkoM;&wsuOx?rQaq-%uHF?_JWE2a4~(fnP*qZnz-fPCY`O^)csO?9!IS|&C~OE zuiM#|h|l`8Pwsm5x|g{sujyZT!+(YzUnhWp7$398GDXd+bFU-U)ZcFrfti;(Iq%ro z5L{QdH6U$-K$SmBkVBE$_%F_AY0<Apd0}rPqf(We=dZR8Qq=7b#46XCo}i<3qsH6v z1pn@x`LD}ja*RUc%EAwk_X?8q$dVwZ|9G0|hAu?N?6&%*#=M%8Vb+{Oc)&2XsxAu) zW3;7Nx4B%*cmYD@2vyPT+dCe&Zy-uhlSqi(Wdfm?!R2YQ<n|aB;)r&^;gx)kQ>=Rb zVM@nU2#i|~9OT=PtlJHX_`}7CnGlm1d~WXce$RCEeiFzF_XiGLEO&TTJnc#6UyKKO z{4N3@Tc|MF9WpuD@}>jT%PNSh!;cNualBQHv3uCVj0As#yp78>-a2xX-4S)nMcVvY z_#$2)|6-pgWT-#GxF;KbzQnW-k5Z$@5QUkaEBg;4V_eiH5kn6Y^o^2~!~9{o^(h9} zRMm1%ioY*KZC(Ktb&F5HtLQ<G4F(2aDKG5CrEIdGt8%j{q||zBq5MdyJV?WUcD`{e z0E2<|cuI9S<#Ic{>(TG@q-XGNcYi{wP)lEpoT~4Q2KtD{&{COQT2d$>=b2|91+XMl zVUZTmqP)mC%YjkuvtpxCvZn_B-HEIIkgxfSwH8PI*4i^AOnlPw84(N!ZMv&@e$<V| zMkL__)hEB`*4_+Fd%C514cfyN=s7=yI=&m8`ICjsnN6VwJZb?ixGyc%Tg<@)Snq(S z{|78)xQUwYM5)4z38j)IC9pUPu2f|xc=@x^c{G(b4y8yT0vl5qh4tYoNF)VWe6xKD z(IC|2AP=%OD`yOdHe+h<?aeiRLH0PS{qy^EP558kzOirW5hLrjP)<kqCFyVAR|K0l zXN+2xd;ObSDX)$^Jv82Ywr!G(b=i9J6R>aMjb>S5yXocpA^@m%4x|Kpcn$0@Z!Cr0 zWRz|7`DIlCwZtltS=~XO@1j_c2rJIh0_47@wm2o)dGfNYRe(heJ-nRpO62|dAre8P zD|DV5WPZ{;K+lIlY((O28UY|Fhg~T5#gXDk``=?(aYg8LqHb!sP^T`M-tfWI<xv!w zyDR$eHA)|CP$=dQ4foMWNqg*OP(6tC)Yi*Yv<Ldf(!+(QBFydb3<Vq4k?@Z7-Vjc8 zLf1*-dvWvAIN_q~-s`QjSp@>-SK1{IE-WWX`Ja|dE1^K=^~>)#1ntPCup8t=Qh9WQ zH|ZYpEM8z}Q8m|vdgt$8CV+5|vJJzCA?6%cQY_We48tDKM}&xu7(}rYLTHP>Fgf98 zgkdBPE{kqK)}cDS@gIlOYH*zFIO8W8d-gLu7l!%ey<zpY7J+8LmiyTJVL}IKSA7}Y zr~uI(dF+|=n-x|4{^^vTJ%I=S;g_WmGemJrX~tjeY{qSwyNF<ve)ZhUIoDX$Y&3px zJV3E`tXcK5$mP)|9O<E|{)xn{Bxq@JxBn7M3{D~KOznS|X@fY{fAyQkuH_Vm<UA{k z0gq3Sa~8R5Wxh<>*$X&qy8ktzeInk=ihPNPjA)P%50%X`IWnjcK2X-<kbKP~NyUWx z;9AP4`f8a=cq`HkGk#-PATERg2U&xWAEgMtpZbz=UlHNZ>`qb$I`4hox4m+gX_SX@ z1pGS%YcGi!8a2XHeEoeE7l}G%YPd4)ag(#Ixg_K9U%>XLHqaguLr^=qy*lVaLZGEP zcmLhmUk$3rp~Iq4^ujs+{92oHb_dd(<^z6_%l<Vf16ec=&L{c<HclG$??@NUDy&YM zNu7|q=J1Q^_(U%|;kIu2+<Qm6V9b4H1*q}2lJr;#kBV#)(3rigB0t`f><E+sOmUt3 z<^b`h{bD`XkTBMZ|55=GPpZ@fG8(p;If(^$=FU+dGHW8W-T}5(gvvKzVdvjk=AAnT zt8u+X=df@|s!{^7{L5vn+u_j>^f586jH+UPMcJ6@ygue^oIJgvFG+sf#&=%0p$m6Q zRUOBEgvJv4aD_OYsIUDMa12G#8Ab;Y|NFzXJfUyT_f0BdEC2V~QRXVW@5lXerkgxp zPIcT#wdG&4hFyQc4LMjy%wn=MZ;eKEwjxe@u&?kDNy|0~(M6n`U9QQsxDO7J0NzF< zSzD9lY`uTyI4yE}1sdF+ZOo}kgd|vbN|cq`=u%d)#7dw7nGuI+L}*H^IXSw*jcfRb zy|V}fB|atkI$?KxD|;-JxqjLfr;qWh=B-AxaqE`Tyzy9z#p~0K7;4F%pw`$+mA2K| zYQDmPmIO!aP+Kjo`G93x760SFN2`2}u~WB`&nyr5KUXwTx#=;(QaDlgxMjF4pK-e_ zb*Wq9Y07FgdQszy^INTmnp*#qJFn-Y;#SJoBB5!jD4Ha~?E9YDu&<Ba40dS=9B-Ds z^By``RYI&McqP0X$8KU&NUW6r69kEq1o|gzM;8%%^Np36FnZi_+oGi5F5Vf#Y_TfI z93(sdQ8#eKP>6RC)qws_MSLwdmt$VzUxb%BXj)O0WJpZaGex7@i;(=Wu$<CKT#4VA ziE$Y31h1-%m;_r%b}pM5|B~_(Gx~ZSC+D2_%8!zyD<kc)IW=`)${;AL@UTDyV{-WO zl#tR4CKp<8*Q6WA>h1iPL1H&gXodCR!8uPAPuA>Jn$L<2Xxbb}4bI`eMI%wL=k1S_ z4)Pj)s-jYNBic|xdwQ?fw(to9h@FXyDp$06#@rCIDS&-$6EKWzsX|ypvVO}`kd?D$ zNZ8MOhX~$;;Uwa@v7NV$Uz)J588<&ygezJ2xJ!MX!9Qpi>cmpiD8&Y#@f_`lV=WGS zF>U?N&mbvlAgDcU50rMEugdR`6l_Uc=lr2{Ak(+&3cZTna4`JM+6jFjZ>?83wqhw@ zDCcy^23n77;rgl`=Vz14K(El&uiAQ`7${7+hUSOX*@_-pvnr>~1=oV^s(GbXrYElD zo|yCk!?~XZI{v`T2Hf~wnDNahfeo@0(`VyH0?u^A0ZTg-g2qHpt2J2<gXn&isadCE z>Z&x)?@ysh2PtTf;C-HFrb>HncBtu>m$*2ej~pBbZayF!h7fyAzB?A7I#e$3%Exkl zcc8hwJUugy*U}z<WXTDeha<y}&>#YgW&ULN_XbZ*dgCaeSRm{w`_xGp!*o^c8#HEa zSW3&AUR#_zDJZ;T!zk0Ke~2B$eV(5@5Y%%HH+)jJrFiQ+@=;R9WcQ#YLqZ(%7}Sc{ z9tsD~_JAR_24UN{LY@u&yq!TP9=`i&ODJd$h5~yqw9sbf+R}A9h)&0F5pgyr`Dlk# z3(}R+#aic|Tx0nAXM-%ebwtjKquF9-K))Rrb0$Q-Db@K68Ibu-n#C#^M;D#1E8$}W zFdzun$5mxP_3vi2{Yd1o_FQAV25;uOa4qhf7qAr8G3U3$eY<3cL>x^%>@A4UFD(tq z1@}3*cOl~Oxm=K~NFVlf3CWTCCFKOA)$<pv5F)rAB{L<$wU!$OVV7o7{vL8B$^qgb zbn^=f=VCE^CCs+6Jz?7v1hp>sBm2rYJfhvTcAFBC*qZhOtBE&Gtb0|=CseZF3DLzG zXXR8VN5Zi@3MQ)wbbh0ph{2RPP%1U<lad)@UekKH-P~>*{1IG~<hObAVVPk&VKPfq zrwN<7q7Z*$<&mF6wH-vwYIXDK@!pLVor|d|ujkOUk<yjn?3kNwvzOo2t=K)?)B8C_ z3BmsUc7Gj}dVBNpv3%rN((=ChW;0H=J__EbPWJk3N?>;U6_JjxEt<pDlugpUCo~rq z4}o6vnC#`V&Y)a7an%`O5n}8xAM^O)93?hrJig*=goiw3WVNpwM~1SsO4%(cAiXZ5 z@cR_0i6{X^lvsx-H&{%QZ)%<?L{SwPKX%1pv5+a?9~r4B&amQogD$EJGsNR%P~Tf~ z9D7bS?(Xa<*k*dYXkumlff2rcFrDvaGK%%;B;Ph1ZujRAa)AQTOqA~h{GY8kYFa;& zcxoz%1&)=28Qo7>W*g=!7d1&LYt4#zg1{HlxJo4EE&}4?Ix=ndy;U=P!tKnR(LOnZ zN!3hjKFuI)@-}?(0`P{|!(eJj-O2rHV{Mc-u~YzjGg`4?`;2VZr_zv=ZXYqU!xYxo z1bwR{1Bxk~<ML&w84ejrV3|x(Gs_gD8Iv)f{-SQ9{J~|$8B7sIhqO7eJ0^_7xrFri zR7PDMtj2Dcez6bXbNL+)i7-K+TSBga<N;1SwXl=Ey?iMi3_m-rFBO7)#WztbR3Sv* zI-f7!gTTbQDRyK)MwkE-3w2VOJ@eCoxcP+9l<e<#>)^S3cHBOOVjY^^`^uMte~+Wz zb>Ea>Phu`JG6(?ILn$3=BM$`X+JFdxqs`KTS%JA~jhE(hNkxTg+Yny}O$-Ri!I{kZ z!;^=s-&!M#8^K#|0MSHoYLQMahU@7xB|78wv>fkgX*r9WUV*O2H15qroQT}FU(`Z^ z0_Bt0yti`tn-TDuQ3!{S^Pq6Drj6b#r`O!WlgGdnsI<oTMuIjt!A<WHVH!{jnu(`U zrh}f#;9x%_12GbIH|0uDi<v3|tKDHZC&XQHpEhDy^?@<~aq%&kagMxA4tk`b<DVcD zb6zmhG(LQ}I42%;n)7PiyF(!&n>_eEUM0@pq6l1^+PMUzfBWwSX34Nr=&oqUCS+<i z8P4pqOnQ=Y*ujcU$;=CJ(6ez&rbOg;oJOZ6ZF*+@IXjgyG%RCZtpw)Cj*?WkSA*gR z^HV=hB^H}>4NuAjEcTsTJrx<^O!-5ieIdU}?j3|bRo+?UC|EC?wee(u$s=^)mD~O= ziNWb<lZ+|n{jh-z;9$j6I#F#R@S}93xD3st%y;3eWTQ|BI@A1+NV?d<j%p%&b3##9 z8GB@IU{jqAak_npc1pEprNl-CEv+Ms6OiZxeZj<7;wEvt_HT-HOqXILhoRU;$|V1} zk`=FzR{3q?_=*JBE+Z<V*tB+6UX)k9(a6J<B5Hff6-6}E+hQV8<)A4?0%F$wfU5&d zo=jHwn35K9HljjFD}`-)Q!1V$X5!UtS6<a9zjh)&_R1-d3K~#72P3(sxAll}gk-U9 zn7<_&N*On@q+jNx=-zYI9*5P-%!LE9IeizNkP#cJL(qJTyY4r(Q+AW=n5wveG<^)A zdbKsa1qQd0tnO_c!7$fK$D7)Sczs=^Sarc59xD>P={@Erhe#vDEg}V7Xn_$t>vY`H zp8oV5{&<8OjOU_I&}aS%iYX&pr5inFZrzn3v-8n_g--#jp97p<f%!M$j75N_b2`PP z0tTzk9_nD+7@xG(HPqY)m#`4d9+{u#v@=WQGY1BZOPf<g@^Vg4j1&xbzKt)4{18iW zJoff#aoe7_in6V1rg6m5hP1@#Fp@OdIV>%orWmYx@q|-LV*vqw$OGnbM#Pyj!a}HV zR=7AjwWOAuVyTD(*z@JghmR>x58d|igl%@Agt*yeEmOQqc~1V?nqXYp5*5w>h$|lF z32RdnM!mh~c?#6cu`w<b?RJ!^$ZD5AW{V3m6vRn(;5xP?hMt3hFAElD4L!!}sP6|8 zel5OJOw113c*ceseJtc(#|{PsUu=tPHqXcKUO|z1aEF4Y`x{@xU)fT?Q@Rw0>v4Ko zo6n0lFVORoq3}p((OO&zT&;FNHNm<IPyFPs;8zIq@kxuABEyy{{NTOJ9yy9|PGw3= zHX3e|VC6(jeDSFBcR7>y%y|(f`bx3KRTf!{xEFsB@vw{l{kJma6z@g_<|%H~4FYAO zc5D6f_2Qgw<*M~iG$dQp^MT}5^W1~EpH=dS38?a%JHu9+-!hQ_lU>%sCAcO6(^ve& zUn&f}H*ujT=ab+sTy9JUQNRUqy2XOCOe&ZMT6aQ9U6l-vpl5z<=ap7v9=5+PH}^a? z-Y&=df_lq~-oiH1+u>2m=4?RhUY<+loMc02=@(3FnEWs5Z*@KL-iaws0_R7z4GFQp zLdn_VVxZ^0JH!@yw^z?P$bE0CO6`o|g3o|byqm#eImoaK*6%Of!-gl+(-s-hRqOMb zBRaWgst8%o^}^U5M`+M$tds(|lHgjPas-g8Hs;2eQEvcAZOj?Cs+5v9`xenLC3wYM zxyjWb!r}90Jg4aUaO-(bKEk+8;=j5N(NR8wt08$-iA{qmT?K@wn<CXRAcFT9AgH`L zmQ)(P93yV3`otfMfTnJ)s}t(Tun9@N{===k2>5(83eiIbA}2gO$Ea?XqeamZ423&c zOBG#Ht*Nw{cQck-zY}-2hMqWleGS**QBQlT_N%4FwA9)i3kwR&84u&*3$YqG|G2RN zy5{2LP;`ppQtkJ$7`Ak=lj!eR8EW(3iSdn7m507Xr$~FS9?)80J2}(4Ky!i5H_Itb z22aZGB@|R)Mi=|yz8FNxwmsny@1NuWuJ$BH%H9UDVC9CC2XVzQYqU6M%paiA$0+QK zuFGy+*SaMznLo>puKsXE755xiUy5Xf?8ql>C)_i#ncM=}+W}!VbCcefYeo8rVVJ@1 zstC2GD<`U)zNtoFZ|`i8p_MDlJv;6Mzr&xnj<0b$YaH(bBX_=|cNb#5=t3G=CvL<I z78an9_d+Lwzr&lbi{9B8R`*E}(tOzsSU$Z5EK~LzBXxeO@P@wu5=Dkt*x#hD3q`~$ zf=roZm~kH|tMC+zMRij?>Ncz=8NZIZLOlywVm(dH%oBIxf)~>joJycgFvXr848tFG z)*YvRx=>^+`F=xVD!3@ev@g7gyk3=KFZO@E)x|6#)NKD=o!D#tkqta%=Zf7$+UF+t z#1yVkin4I8ALr}OKzpzZ;QdNWtodnFJ0Ct|Pm~bA^=nVnj0a=0aDU63&*(;q1SOUs zsNyd&^@&H+9Lq}{k$iSZ7hmAa{bG~L*j-JL6T{}BtFytwRf0~%6#xtWo_;>MT>o*Y z5KhXG`W0O<jn46A{+Er+<2FbHvI|EkiULKI&++~OjkeHip-Fn0W;tK241zKM_WL4I zQkD9x#B6_k5J}#I%exztXb}`1okLG2_d_%Y`sv!iP=}~R6*GS1$KBa-%oa=bSyOw~ zC!#?F>QC3=y&vo<hN*Q@!+Ii-GcP8?fdLOf!U!>k#Ug;>yEgjm|2_1bFzqB~s>%xG zLGdDq=6_RDBdvBao>*E?Kq1r1Nv)MqL>U^<A=O~P$D3PSn#+URFarykCs%?l7TjUg z{RQK#{^2S?B@-0r%4~NoYOXGq-3Zc2%)>NNh-U}6QBOW(A9K4X;ACBSL6!u*P4f1w z62I`yc36}8`c}Y(#7ey!$Ohx)bux1u+$Y;yPiw_jVLj}K=PJ#a6#l+e12vxL^4w9E zThnb!O+K-I<c?uy@x$F^wi&IyDY_?Qf1V5m3luRd9lt{z>3x8q<31LxQP2y;GPL4p zxE;Ad5e7wPTF?`_O=-pU$(+d>R;Bv6F&XLOq_I<4jd0~Er^0Jo6bri4!80MY+!^B+ zw97f8JtFZZYEiR<1v}G?IUKA6xKVsN^V9Xtv}8q<ZM!QEt?$VggGEGNMB`<TB6M@! z@e`9t)J}w4{ah6^Ouj^WCC#}y^jD-ov=TYl@+1fbQyrVD@?Y(E?4*_jU7?TKRgMMU z73f>*_<@2kus~bDH^rm-Y?nf~h5VOGsO#bJ+}H1+YW2EkLu1jyy~`*$s%!LDuJRF6 z&C!hu*o{erS}qhWHo~fa(QOVtO+;w>JAhzAUWNDRYxTY3BlY6#R_w(j)Z+m80rz+^ zjru0VTk<A1RNDtk55{|pbmuTt3bw-V{@7Y86BasS!Pev_oj>Mv&*!~wbA15z=YDF_ z^O!tLblyk^${qOoA-r9)d@A=3;a0|TiNSV850pgbUaaO-eScV{+D@+7i*=~HS<u*= z0WYGI-Yhm~q%rH*A?U{=ha%*>he5bjJj}z4IpI1IqGH+Zy)D|7k2S{FH4+%ymTJ(y z=gn@LpsImkPq#0?r8&XS)E|982Uf)l>C(%t#^!s;maE(ybb&5=K>2$CY!sBDG$Ls{ zzMz@px*bCy(l$}O<1iBs&py+3yQ+$cx_ob&*9Ul_L(s+f2ZHx;DC>cr&mnz?LfvHR z2|nHzYEh3q39xKtASn2w|Ji!z%$1O)<G+znLfvk6<!<-<TdM-@=n-tHKZYQVN6T;9 zt@OIR-zlVHZZvpFYj#_dA_?Eq?`~6Y&ZthsKK>M_=Wn58T_)WG9O7Qj(*MlxbG1;T zCyiChV>vin#i{*vXE0D3PB|`fye-7MAc^4Ke4B7)BK4+<Mr&fkjBMH|Rin(^qPX@P zJ2Q;(S9*~U_^W8;ZlpN6bY=2cS)$i@S1!E}?iX?Y04<!eP%$aZhqRWbEm0MT=`JY8 zQlsQ!wzL*)?p9u6QOnX1zScFp^GNyzPr{~XkK`YF^CyIgFpAEQSvlsS#W8>tH^0}c z7*wE=XU2Kd7MqzZSz_}LMkXEZ#M!e@1Yo`A*t{jdN*HKo3^s&vU+K+#)_=o$BD7%n zp;MM0RuyWV93AGOdqb9%LRRW2q+L(&p`xm$D*-jGqe&A2U&xPZk3=E8D%^_&;qxlY z^0*qzk|10A>FK)B>dN5y37HWctNrO(E9oqBb+21I5>a^7F3X(Gmad8$@wm>cSlxmf zcHh;}L2kENje2Jj{k)pVcQd=kfxBYN4TxAI^pA(sKK7`AMD)hz#yFY(I9rqe9JF1U zGF~2`))+uBASy7~+k8({Ab{*FW9nHQCu$i(*w)M60YHnOiHv*(C;p(6S}=x42UFsi z^u86mtij}Y9n^psE%l$+Kt>X9#_`xSkuqIXYv{3*>1t=0m9F^ADY5$V3!AkRe%?`w zkpg{zT$@%r0qh&X+(YiMxznIF1uhUk#Ta}jG*FUD%J)C?*tbX=!ipB>He?5&v`|CH zW`*X6ZH`n4U+m5Ku}O?yfVADLV8a)0#JrWul^6m(pjYtbpaIZX0#gZhtdNlP|5)z+ z4SkTIm-8M3`;b%69P;gw(nf>lYc1S?ijq}ZsB~}DOF$oklDb=6hR_aFGp($xZ_f1@ zv@34w27T?dFCKftpty+PF4NcB@{J=nH$b&CouhRKvh486m}worX?t#+gp|^9kPZ)Q z2r3)4n=ah9wA(q`Xq90S!lI-`pEdzUy2aGq>8T07&Dl@)Yo=e-aA31(Az#4i`#a+{ zHdLde()k=uE>|xMK`gn7S>3AZ`F8h2nde*~&Qk8Z3!hfWpn8VO_C3OY4NQ)#16*Ni z;s8W`6P}x=6k9(W1o*zGrw-}a_4+4+@57p^u9cpurWf}1o|LHBY0S_{l&|maI?#UQ z)J&>lJ#w6-uJC6krX@Z18^Oy4rym^X9ye>b^gHlWQYh1;oZ`NQtJ(!<)Cqf|OgqpG z%It9S@S~19b7}o?aHo|9MOYorqC}vMm|tU03JZ*ZZq0SH1k{J3sx)4^joodhd(EBt zivuLKTEJ;<(1)5=b+1(#rHk7X=Vbunji%aqVBH^&^Lseq+yd#ROj{o>#TnnK9-feh zc#$X^yT?vvZpI>1BOfj0PRL9?5aLxc!=Z+U2Woi}#^ptA^lMV&HJJj#%l*6GWtBZI z!S0&cDM6dsAUOo@2oiHo+z{qf;t)}9IE>UUrWTf2llQZ|HAH-LKy{QnQ|@EuyUr^H zdSXy6){XDy&GaO2=h^dC7ra&uW^Qh@c>d)}-Sp=#JSG>Ao(zL+MBT3A*}ft}v6BY< zem-3Ek*$d?a7>Z-pugURw3Z1>fJE?3CS}QfN<}XAzpj%Ai5A_5qx=(tbpw>%##}zt zS;_>+Lk7j36!K?YRGWDid7bfM*szHg<qzr{%<0%8!3W_5BazmVmJqp9?*T#9aeJTI zJTfD;ssVHC+XvuPZV{1rv%C9Pm4Bw5z1N}yPM<N65sF>LHy2xorhT@!2F~X&!4Cuj zz~kCCC5zzLbB%@+Y?z^}|FpF(49IPa+~|h3cxKfgYl~E(D~-fsyEpF@o<!v6y1G)I zd#ZR_MZ-cqV^9T}_n{pD-1bxnDHeq=siY(zEm?AYnU$cufDraw*T1k5)bL?8Mk}vg zuxr1M<32gbnV#K?3_Is_4f{G>R+#b0!-yB`81iJ+)AQOprRS3e^FgofJ04Euh2PiH z){f!a+z^poFXdN#VzfQ_Fw@__RZbA824+iyf2V=uLwkLICKG=suBmZY0%%|UEM7kc z^_o{Z`>D(S(scz(=eEK#3G}#}qSj(6pd$s~KaWY1m()2F4(`zyJ(?bm1g;ZC0j-r5 zYoZEQF^|3F;moiO%to?)0Ccj~Xx?cb3hud9ed%4~h@*mcU*sIA@*kyg+r&TSyFbUS znLmrV?J`psJ{Z$JEs&kQ)TX<(JO7kZ1f)ZRD0gS3DYt0N`MgP5gn}^`frL917bI}Q zKByRP0rkRarB8y)c9@(^4r`3#QsAgm;Yk8y*3l3{u&wdzLmmJI62F`|alCFK845?5 zEOCS+B$xxa#^);Xl4nA;-r+=W8aRf8nAGU}Be=yvnh-bhVqEDUV+&FHA(2P;3WV4e znqxA8GTQ{`6$Y(oMT0}WpP&W@#^eAneLZoY5u(S&ixB2sMZCp)2Xk$TMxQ}Tp+FLb zQ+PZG%v*9~xX*&&;S&k#i+3TXuw*Mq<{$!}(k5D-kfRniQMM73vgSKXc9e4_SelRQ zqLi>&9_e77n&&{NH_c(j=ZJ^Si{ct$`ShI%Uh9@5H8N5}DENd$XDL}SUeI5Q(szD^ zHK|{RjN0GboO@JbZhhhsd=*{9VP>_fL2&w>_5-t*Q%4*>Mdsn(5~`SA_y~-jcOtM1 zDTS0*03|Rz*#zmaELFh5N97nVUdNcEXT;5Dgg|$>U06EF_t~DACbTH_Qvriwl*@{z zEJ<6s)htuEP5#pr(J51SuA4qCU8l~-eq4Iwywdz}3DJ0~;EbxoM0OCEM=q`Uv#H_D z?6^cS$~KHz*ki1`^zZW8>B26ZfD<n%mf+KunG<Ea-`_Y*I5a=g9_yuT_<|(QJ?l_G zC8K)z4CzbI%~^;SuaZpy0rTom#b%plH&xYdS@ru+xR~U$xAp<sIp_jdfuM0HUHoZ| zN;;MJSEu7lTXD*U4ok~4!h*3I=G2DZu2s<lS=EHH?{==#`Y#p<J^jOui0&)RXQM~~ z-_SoO+o*2$QF&Rz*?)K4HzJfDUbOV>@oQyrKQXwZDhh_nJjv7kT4tc@yCniLi5!c@ zjUwk10JriWQyxY9I@<2u^oDprvvvOz4TB<{zhIrNS7yB!`*<6qTaySaglwXA{OCl( z3fXWWY>oOoGCFc>`^;2p-rY=Rs@&!0?SC%PpI`oV1980XtQ?xCK!m_TgP^%{){<z{ zw7#Ax&}fBgkFHJEtpBmb)Z_U%nanePT1=@VAxZ%M>tGLpG7Fhf@hUCNz-acBnz*+@ z3O*LD_G(*cW~XOKZ$uHNW7dPMRIZ&{?mKp}9Gk#pVW>fG<Y%JKKI{vf?-~YPa3Mxy zW1hcB3+?q(oDvY;p3<tT)zr$VsEq}JsbZK$ttkN>=Ti|XL?XgPOgoo8AOoLzt%`Gq znFnPge$u&JG@qy<I9k;VPU7S}V2HR?HKr+~aN==DVCvAh?en#Un-nmICwRK611AC^ zU?33H6#77B^(~W*)-%a@^uYuIDy%95F%09X>I@WV1lz+`kmDzV>mOfILZF1!dhF{Y zux*AVeap_vU;w+=Zo^nThJ!C+j1+N1`CeN~Khs?x9dx0AoTGl`!GSccOEsT7NA&7Y zKP_R7bw*xX_n<CnduX5rpeXRQ+F{vhw;1P0AiQ2~CyLlrGttevP!14p2i78?j&dm| zu@Q%?P(H_$EaP3WRU6en-L-H3V(6@(e_h^uSEVYVGv>dLKB?J6+E*HgD&CnkRmjfy z!Opn1vzgDyiLH3b6(Y5wuTB9(P>I1it4|ml_}ELdU59&cQd$>Qur1XYVH&wY79c7o zZ};rV4#;2h{$A$FO(2jH`*WA3qb1vjghEE&?w!AVI!W~c4cCMW3TYHZ;ctASSE$HC z>hbvERb0x8$?tYGop)Db7GBVvh)Rg-zeh!i4LaWcxU5cI289-7Z6uBYc6)fn$qt2v zc^9ME8&xL=lfbHcLCUm4st#SUC6Hs4EYWV8Yp3Avc+C`*C1`b5u|vk})_(xSi^wV@ z^%rA7hy<K>%@$ty(`)`artI&@`Xw7*alyeJ+Gs{Fg4CX)CS{7x<bj0vqN|Dk%A`q- z*R|>+;6haW%Wbb|LE5c}x((xR83kP%SugY#YDK#H7s~)Z`gSG=p5mm5dUy4z2d6)h zr5zfMm8Q;Ij#r<Mx}!trKKt)PhcjUR{l(U`JVTW*m&R~@r>bdS^!y8q1RbZGDJzyx zZFTdygV*b6j1T*M3X*0BS*KsM+ugWY>szUqKGZ2@+TI*uWNY6w+|BRiR}f6uzT+vs zg*Q^$pkAN1_U}jDM!JGWMj=GexihNK5;eaK=!X?Dr=^L~*utjpkx}ai+OV)AC-s`n z+R%s}%jnb#myqXF-XTm1+9oUi(L2lQtqEvw*M~-KJM(LOj9ujt{>-fVj?ot@2mbOS zfv1IG<H394=;Zhsfs-8qM<<4FqC8~JjcH0)j=O@JZnUt7Cr{bP_Ej*d_J~p^zB;6f z^LQO6a{EjdSED5AiUuV4n-v|ZE5V6}o}pBoCX?++iV2rih_HWE^<8DSj7ycz`;H=C z)=KwnKm)d8X1rlZis);1BUdEbx{9hzwKXk?2qnwj`u0C+W@Np+<4o)wKQ7b(7|Ro; zwgsn~wU2^qVS0Y_(mbNeoakete;Kd(OzOFsXBaps&NK<G`JJb2kJE|sM$AT?s$ui8 z&C`)#t8GVQyeBGuvQTKr*=Z1<sbXx5k5wYAl#?JLUU_)}hCGPIxC<uIwIb8<uJnN2 zpkiFd?_ueC!ax7Up>)-Ize(W}B>a^JK^l`870~f&NaU*T_gA}{<#JSV1Rww8L@<s+ z$|{98MK=DySw(LB)-E|4t&+e0mhta5b)AeOGH|k`|MTD96-e~81QJ>{QyEih?`A3F z4lG6?(8^#BRfH7j0#v@oIcujPwu^z--ooP~Uhzsv{Iok(QFwy&UsH*ysz43Tn*?ns z7!EW^aw%(!2}>(SzbjL|XF;~Tk6y2}NXm2Zef*KL0|z<a8TI;$e%hQw)1f*;RLE&} z_kAk?XflM2e7LmApR3MgW*K~|v<1Wqip0{?T=`Dyw6_-xrq%o}%<@<sle{Jx_8iCO zf3Z(QIQyXc2;`p&i%fk)L1PS3x)w+*b!!IEFUEFFbExa}dqR8v8sYLq?)NXIkt&iz zavD3*TFcOWjjSd6nK($fKY}<?V5avFE;Bh(CeP0Ss5u$nr-JTKuV!v>5PUNptS!`= z?b9=GTxEe}F3#;%Ibf@IHOLGZ<!__09zj;@^u%~(iK%bgRK`yI;ESnY($OSXS?G&j z!HUnsG|_6_48m<>CyR!nap!ra?bZ(eFfL@|qiHXoEl+T0(W$JeDiqeT!Jj+L|9NUA zsVie9DVybelFsUU%3)*`spefwlDG9}M3t6mGGt28<xAu}X8&3GelPF2@by=vC=1FZ zYH4$*>^jogAgV_a=ef!pb2Kvw@XnIH)i0pYcv^bPx-;RVi#dN&=7o4D9)j5tiA7vF z<v=7XSM7-Ip1L->>}-7AV{o9uA9_RxRLFEefKcCXWleQH><Qa-#158EK@;PBJO#90 zHZZw>yB+f?6Da2rE)E$8mL<R!kWS)gNC0!5LPU^lELg}u|7=)UZG4a(HK;dM*8$o1 zDRn94SS-pg@Lo{UfNp-evY{8%<>yU$GLy?Tc_@oqy?D~MGJkpQyhWKIAbDUH^Prz5 zXyA#9aW49{>k`omI-hokLE&Bi@c}1<0-Tzvx3xkh$D|f(_a2l#BcFK3@1uMcI<K#S zdN_Pw7OeMhfVJVs=`)}CFerOpxkyvb0z<hLp4s2W!fdZbW$0nJ4bbvVoon|&XNjkm z3-1t<@7?tOtdEgh@|jr`<2$sk*S5wG#tSx@UhB5A#jK+5<8L!4NNrCI3qMp~HV)7x zx+2+aur47jC2<It6GnYo!+O-0B0N|q!HvlKq%fLd^fX$l&FQx)(v#TB3-0~b{D6F} zrrF$3+s_SA{sf`fJ^!llBvy<q+26OTt--Aui+sw*(a^Ke#+4_xgO|4G0>ajdqrUD! z=BH)Kwmrj$?=nFb8rj4=crzCjcdEr#2|E*0+gn7Cdz}k1w8SJ*lM*=CgR+<R-+^$~ z&SEJSMu_@*zKnQkj`!GKeKq}Tt&BIf#%Y9vP`ZkPM_p)K<VvKE@ej91w_a1dvs!7K zBO_r=FUiN*IRw2Jip~O*RIN}E&LaMyf@)UWN?S*+OYO`+0s>>UJzYK^ATj`L-7IoE z;VAiB#^@OS=1YVv{)2v}Iei)9%cknVjaU*Gg1LTuhBA5-0i_DYG->6-I9J-8Vp>On zyOkLssjzi!XJ0aZhm$iPBPq*vczsJH-96vgviknEU`nnPSGAV?89icU5ni=FIgVl# z247{P*m3NmTRRdamlFrVUsIdB+$<o7J@Z8lZ&BP3RT7*Y5Wn5_qN<eDu*M5ocj1>N zn-|#WoFJj%`gjD1#u_v>f>#jU)qrT{Et+Rb6}D&o67t@p>-k;#Ec>ndo;;a$Fhq`Q zg{L;)X?%gg@jQWVmEEQ=Mcu*RKKFiUw@t8W5WGO?=R%xn`3kyZ6wi-`0<<-?LZ-T5 zjGs{AT>Fvx`(a0?r`6EI=K`56L|u?fRqcKhcM?r^DJRt%El&nd>ZYdXTtodW>28ig z(A%Ti{yRtu(glDpYY~|q9{q59!IiJooN-~-yGg0fS)>M;4aG=Iw+eZN9}t?q*{r6} zb)N8F>tnX&QE_PBlA@gXvs912Z?b_r(a5d30VkPtATj^X_+b3X^QM0C*ft2~PLZPg zPGKqkA+FsRYM}&<ZwGSz(BkwE?3{~b4W(F$l`WTQqu4*d$x9#%_BP3uoF{D)JL+o- zV8R3}DZJUl_Q@1QbbI#X%$S?T=xs?|_d9XJupXCuMd3j9HJ*z2WpXK|m*|e{^-hYC zT<|kpydu8^!S0!Ou={uJyq#_>OZA#}EumU>Y8Z;kvHPW}_p7sqY<(n3q(M#xR}_C^ z#X`a0VwBVRUP85@+hIT%(TQS?*(Lf2R$ZydG!mGatlFJp87{uHAYGZ1<FbC^Nvr+^ zP19yYwK=3Vsd$qKl;7o9JB-44=1WFk4X<x#89~i$ciB%z2Yi)_F_hQu&+$VU54=ef zhoxap7W&Z53y`vLAp+PW<Uz-P_Xb@o2Pk4B-0uovfP`7F|JmljTh#W!O4sV5vi9v_ z#0ggkUboP(%OP+e)ymgBXqK|MsaOx^czVvlle*JWI`)5)+LXQ|i4Ou4ftA>#f<u8l z4$&8&zIR!EuU>^a(EL~qyEnhpubW^W578Yvv%cp|?})7V{O183C*H4(A|StD3DiGh zs8+!DSpBuk%fsha_8LZbxTd6y8kn(>Xl{xNfmzI<)r~SI7;K_?_0$h(3s)`m6rK`G zlD!X*tBnN(WU1hCZS$X&ZuH85+2iv#>Hr?Fqiq|(o9Xqx02&AWrb8c*MMU-`rW#4U zY*{WFa}Tw9r~~;>>hcs3rmuE1TD0T1)mLTA$Ze}Vm6~Tmv)IJ+BlS~&Zns>LxH`yg z+w4W)CKCFj>_@9AmFG^U=dE+g7O4T`T0LZL!~xSbMI-;uoHD-7fIumHLF)+nK8y8} z%<Z*r?N=QYK$00$i!RJhrv53Zhf!I%WX?!I#aR$Pa9jq#Vry*c+;o}d6^1IVBhK_I zr0G{qUU3DJ!n&;KUe*4xUOURB;#M5-xRFopz)&33`Dqk~W>Wj*-wtu`Qv2LP4BssK zLOIQZ-&6~XLA-n8^-30VqkFi2A0iYfCQX*_L=GI2%`=$YcSe|M8_*i$Wy9A3!PLD2 zp)~@ZH6lsgaSxpT57Mdwc6khv=HzHo$mVSi)nuHDjRU1{_Q8b;GQj`>11VQVl$ip- z%cr`in+5cvsRUQD_yyjb%>j;s-a(8qWm@kmVMWj7s@ua|FJ`OMRTkCE(^U7G?kQvC zdDjj#H|#28P=Can4{1pOF>GY}eL85`iyHxr&9dhVB3pZbubqNoXy9KP>(lZeywU%h zg^7R1_@<c9=<!W8?$EI_l%Xzjq2w={hjW`oSn?>k;U~byrV)y&%Ds`x8-rnQu;%Sc zgsf(G0PZ;Sy?qOOq3vl!*_g7tt-Yo`H!m4uo97k$LftTFipk!hIDufbg1^l(w^oP7 z`P#}UqD(Lg?~mu%o$W>#W6)s(pmAyaykm&pt-rP>7LeZ{Bk>V@L8_nymi)H;I<a~( zQ+LLsOK}_&D7v7Y@dJey^nU5Ut8cRPUDQS@fBk0CGOEbOyZzJYY%ZRiN=2e4^iuI+ za!(n5&7!3!xz;XtSTY0;Hwf7>jTfPDaidG1b=hapMcv&|V;-x^UlykV%IM_Bt5<7s zlTDb#J)2dYCbnlN`nz20D&Nb4V5|@h1D|FuN9)w`)_=noBfOH<`R3B&YuqW1^Udy2 zH@9?q;zlE?;Mq!R#)G`|bRctdqsF<8%9dyao9%8-K2hn;m2P{Vn(SX*pqo$=HPghM z)+2t=ctE#!f`pGN;mnt<GZ;qD=zM;{QL;allDYMoVXGue&m--6vB{?dcEDjZog!3p znB_-nN~ExRrIb*qlRA#i!IZD+-geC6F}3`Lp<;b%{j;7j=dD#G?x;WTU_h&J>A|HI zIQ5bGELYLS!4oGbG!-MHUmIrz=PEP0fgf~<m~bR?W2AqJ%%H7X?;q(mUP|d6!KlZ1 zY%xHKkncLBiF~*DCnSmFLW&50twK&RCQaAX>&7fmoX5+5AIu88r-Vz<8GcbKj;Qr` zJ%j%2kO4sk-?an*XqtAK%(|NNZo;jQjsxL>ED1V@v@la)oik;FDn=PDb<@pJb7RVD zS*D78p~DwgTj$t`Tt;^{<)W57>(Butk_tvp)A^jV#3pQJFAg$BQUpz1U-R5wR`_W= z4=N8pVY~Xi%PzYWEKBD9nXF}FR{Nt9c%!TUe<_Pcg)Bbz)5E=}Z3FGkJT@9<Eao<7 z_lt0ODxPX}m(eQ0l=P-3E_NCLDpyFtxox_>1Sb0iV20wS_dR}idzAjT8+H)$G0_{A z84IH$<7U)nJHP8NQ~3QmtaS^G{~6zaZCJ@!2VOxj4C(g?)?2(f&XE<Qo~Kn?YXN3T z2Yon+ZgrVY2RYT4CP;+BYFd!eA^*D(udVy{!%I*CDzd--B82g8|K1JqKVnZc>Y-Fc zLRH>cUroCcX#y3o4>qTgW8(FooLHPry`%xlsXm;$#vqh5FVDzAUDZ6}on+nnTtLEd z{@`>xra`KQ+#0WgjH=~fZ++~R(kB^qFmo2mX7mHhDkL3o%5nN43-{o`&JkixHguh6 z%i4+J&%q=!{$EGz0}tP!19aT@1<}ni;3zWl0hu<!3o}yy)B~~&So!{nB+=ZdxEG{H zOR}DgU1mR{!Nv?=?n-buzK^o!nEUTzGRCi$$>lH0CReBb->_Vm1+akrSyWd<3L+8q z33VZ=&$Zi5;un9&sJ_HF_Jw<L?Z({Zs4Q{nuV|UTKpT~tgTf1wB!ItV%1cVuP8_Li zt1jNaR*%$?R+vcozQjLBm9sU8Zb-@_Q)z5r%%746%|_GpAf8w<UArBLO^Zw``vsp< z;%N)eoT(biM{Hl_Y+ld1-v62En}o2FTml6GvV;NxLjRwsK5G+q3nM$*|3{{;T6Hsa zlMTsdRUOV%QGYdV`%~J##k^Hei%2l2CWy=jMK*?P0IfVBshjR=4seF~BJCO4V8m_1 zM!z2ff6tWaG&7~WnC%v!Q*dmn?>T}f=B17{IU~}rh`GFlH5#upT7<Zos4ZU+!y;BA zdA?^vW<q-|2Oj}S>(^a4q7fT)P`-da?7#}BN(>Oi8r{S|ObmN33(|CG;m?Hcf1<iF zx6zjE;q=U!9wXaoHXQ_Ji@LmwS~F6-vMB%O+4=I6mCSr&eMws5Q=h9><;KVV5XfBt z6mmkWs_ZIH2vHdgdI8jAs;YDwATP-WmBe?2@zfoq)hDXHDOU`~9sYeIRio|VE8To* z0chc?a<HF>t*CCeTmt8B(P=LI92)d)&J_PjR3<J1qq@Ti-9!eK0fDZvOaXe}R%$Si zl@U{3igp``a&uVK5V1e8gVJ^4g{UFxE{?oxM}z<qrWj)mVXUO!6I^@hKy!=T!Ta&! zmv)_q_KnXK9{42&RP@0^LKLiTGvBTr+B>Ehg}UYm@Ef<1vtk6&=a2QM*TiC<k4fGP zBSwT!fh7n`1a#*<rp`~~1VDRH7q8OR1-&&s5TcYP6Qa(@aM$ag+I8VOk@FrP8X)*{ zd#XqLW1EPjsz;-oSTqTXCkdadI_L$P*obW|f~Pwuh0=dW1(C@9Eb)-fSl6>r!Bz1a zyA`D~GIDETbP!4T{d#VFij)ZRQf#o1f$b@50?s*t8#czCw5U!fh;ZBb(1U5lZp&ah z>v<$j)*oVX>PJ`+AmcCdt&>5nh?~-P=xc-sl&Ru2`@v$q8;2t-LQ+G%pWoH_!3p8M zJ&9RefXPK#{X=cm!SmerP?ngOX3zb;^F^6SeX}$|6z=wgom$>dkK)JAL{*ECt-p&( zHqd`_<O2|yyD&uTOwE%e0nZ$_vLjTqcsZTdVh?Rqow<cv5)xJxJ;H0;8LivbF-27b z(*yit0f&Gjs!+IYVl77<ZqYTYB)@p|OoH2l?w3MJKA{`qOh<G7M$PD11C2pNvk&G0 zlNYG~ylW=o5PpbP+UJ^$OqTsC*%hNkJ$wYe2xPRL30stXhF1%@Z#D4Be74hMb#~B| zRpbPCm|4g0IZD%({&if0u6U)J9TmMF4%7w0h%OHba5vb0!ke~abJG2TPlFFx1e6VV zyH8-@9Hq09fZg@CM|+Oi!vDg?pL+64?p?!q#e)zq*c^J0HL<7y()IpwIm^e1+t3<y zPzkR3YD7=k#w8j};Fon-N6SKZ$h|lP?|n6Q+l(Vclqd%hu<Zx@KM`>#9?V$_1_adc zA0klyCn8+!ER6nNp<f+US*QO1(S50Y#SpfEqq(TNC@k)9HKa_ji0xOT9<Ci9E<gk7 zpYVSBi9uw<4mtTXaI@)Sx7$-_R?nJv56>HE_QA3ddLH=$EtG3r5CrD=k;>=TRDFu1 zUO74=X8C9aPgr#-k)3rug$BtcE+xbS!DM8#zWVj!H_HCx{Q81mkx?&aM@X5}7cX1J z&6DRuv6LC{B9k+Vqw8?4UT)Np(zAN$1+-qHcDplgE7#Rg@cgk7)0VSSyXySNWG`XN zt8c|r0j>v6xgcuBY2INGbSM5I;9&1K(hELz9NLxDr2PIBkqyV|1@8v+r^KIRq|X`H z8n>gTcXQ6SsV2W4;i^e8brbF^ip+~?JW^c-@jz~+)&C%CU3!e(oMFYz97^Iav4>A% z^oR@uDU!9C&*@K7R}xBTTHC1AQc~bH;606rv933A4|J@b%qz<T;p2s7Kdq9ck3dvg zMW(godODOKHtWJxxKr#u^V`?wIuMdrzy23IceH!KRffs>>>XH!g&CBp2oLp&fJ1D_ z81EzAoE`4J=3ILBp|+n|bffs+I1(?|XwW;0)_z9MI8cedSau)%{!hkMyj_(5-I-Y2 zC&6NWj5`4Y@As`mMxa`}NST}4mL~29o3h9j!mXzAvV`yP39LtWCiUIXv=&vlXX``r ztP+n%nNn|YUJ7Ps6cWREJ}f=AU;`jI)M%$G48AuLd*)2P0~h#sp~m+`QE&X!QNb$t z&34riF&*;b>Lnwxzxf|4=^`=uBMGrOvm>YRSEb~0LWg?j;5Kr7sc&T;(dpj2WqRe# z&6r$#W0SyDB6ywQCquRJj$fBEaBZdhzP<nX3s^QQs!w4I=TIN`?tAG0`vbJa!J|Zv z^wMd;ktRO3#f(4L<9j|>J|`tjBByG<GyjTw7X)i6{{0;i`f8#xSVh}s(46<z6E<sd zQzDc;?a4rDV5{YW`1%NGtR(_sV(adR&X#dV>5ciO6{14<Gra_XeUCQ&lyf;l4T*#- za@uSFfuWxjvlnVOy#q%5*k^xMjY(1c-)vdglW_XXMbSm_AxZ7ow7=9-O&Q9=&y352 zzs$f>5)olT!wC_8@w1pRIUd8MIc@)*V0n<IbTmDj*BsI^K9=Qkmfd7~--Y+eF=U$P zuA{aRf6)OQw@P&>A#z*fl|R#|s*O2QZP9Oq0o?k*=(?oqjde+xYL2rOR&?|+s4wGF zOcwLQ6mO6{M~wwKp|{P{O2q~3K@g4$Pu^%(b>vf$UPqr}yV;_)DZ8dM7DR~Rb&(>| zvLtxeK{63<#=LdZ?GO)=J|k7!@cAQAlfq}xGn29izKZ|L$<!PgO7Bg5))$7Bej!=E z4tmd@SP-nX#r_zFK&v66sqae1?H2*Jck~!gi2Kno#Z5d+X@AS}gBi{>6sRQ5_zX~X zOGFdMG%U{k|F5#M463VJ)-}OhgZsh)EZkj^-~@Mf_l3K=dvFWx4hstem*DR1?g37| z+PCiha_&B7?_2ZF{4<~G8r7qFRQEeaKbs{!`IF`{Ii6cD>kwZJ=I6R&9Ps)F>m0u# zk>u5Q=#TruP4=*ww4X8b31Zw#mM9}qN1^GgjA~K#KB5DWTa;(N8nny2PVg2Zp8Z^O z*L$mDx(*Vdveb;|HbBlt-8->0AvWU|*ju9|6>zz8xh4HG_I;s5d~5%GJfebwfWZGV z_WeE@xtQ33EbMHZ{>>4|M5V`e`*#F<riUG*LI9fF%jd#JKx%LewGq;Yod9vv@zANF zDd#Y0<CKZk?<gEk=69u^Bo<>bAqC-g!0DTwcKtN$EK5t~is5s$dEu%P6`3=`F=8W9 zn#0a>9NYlaCN^u@-mHcgl_siqclOqZp#o&3vRmG7<!#@hOXjOs+vw?~MR#WaDW!)M z6!B_N`o#k8LxTr1qs0pnu`~hmhGUH7IF-y+nsw%47+E>%RuqgA6NiUztF?oNAV;pE z@j4!)d8EmpW!je?sws%EJTINyfsQ1f#-dk3fYWVa6k^=bEn0`2E~Ri)S+;PS>p?d? zTw?V6++As_lZ|vmhB+^GE_zXM!>AB!26f{eqo25Biwl=MzGTH);7VaHRZ!GmjFDOd zp6AbH)L&eP+cqY{FHL<<XLQo{+*xF9A)_Lo9wa}CUeJ`X&K>lKNN`J{95T0eWbyEP zxj((d^~t^^8p@xMVBDf6)fSNz>zZXIIx<~p+l(JW{`hM%ex-gt+7T4*%{>^17e8%P z81`1HiQ<{aFt2|NpIcu5of!JOyL~e<?daj_x$?SmJo|EbyV@JN-I9b##j)V&=}k<8 zI6u<Od9llrGxW7`I>Lfh3JE50U+!|>TwK)gu<=@tQuE?r^f8Uo-rXQKgsQZp@^k+s z>Vp>LQ4^-0&PV-Xio2@y4we!I70F`4FB5lh>jg<!;-hU#L-2=0L{m|&V1*5oV4_rk zWq}K)UkGXLsdKCanjpIJ{<wPKEFV=TyF#B_98?!9YML}`2hh3ay#|3Bt_Ju=1(wCw z&1io<>>(hEUHhO+UcR~W?g!~wurK6vEZ(KG)^QfnLDDuW38^7lQj}%wY?k!XJ`NCE zyk4(;DuFUXbn(nwsTfU^3*@a^7R>N+pJ1Qtw|7|yMH~EefN%_$^p7XL(tp0+m&nM& zkjXwTEFPPv2C*AieI5cqsRSWiAJoME8Z^SAedMVQGFcay{w_XTi5W$d<kouA=yNBd zW7x*<zNrDew;{irpGFT8S%EPUGH_lWL<Ji}a8f~;OX^xFY9&#StUjrfffVXYFVhkI zsj7F0v9ZJkE&co#Y?z3YnHswd<iudc_w$)ZQ7R*GSSim96wPm;P>1CLrSHL;A2@(> zl_9v#i;w+UZI_QEoD#<Li%;yN^RlcY=%{7h_FoQDe(|FH-dB;azuubgL~FL7w%nfG zw7XnFY7Hhs4|)^ub&YBV+Fb<1U(X0od9*`>Dtyuh3f}(P6)5bZbOlHF5D-cN5D=Ju zMgu2%6Qh3<2C}r49hW5%y!X|V2Wt%^Wv41LPAB{NgETuW=CbcJ@3{AdAj1LSIPm)N zew24@6i*gH`et1<UB(kbqmaTH0)*``>E?*36%`fWOz=j0JNRzQ%UOf!w(<FN{>|n5 znAK)Ky1n8Tzn1ZJ;n1)lyT{F-w=Pw5JA5zKD?0(o`b2;<qN@u_>9CgG^USPda#2;; z$Tw?F6;+^)qDm`<GYSHyjSjS0>Z#*yz|X55lg~<RWux^qkjZkmjJM=kI0i@KC&ks0 zchtRlj1KP#onq(9n&NdRt0c;fE9{#!PH~;<?u@kCbxfjjk|j~HRX4)tzZ$1J_ZK-k zA_0ul=0xpu{B^%F)Kd>dGf`<5Y5}x7Y7*Et@+*nbbd9;ZnAkN~?D}n!8PpPCT1M+l zd!v)Eo5zWH!8tpv6UArS!}rT&FS2`fy$fR_93+<y*j{J*C|q9+`J5E-kZ2aPRONM1 zUd07#JUSh0CXIRe2urW@EprM9o4fB6V?&26Pb2#)g^RR--wGy;S>u(cnSQ>5HxVGX zj5SegO}De{fXkYpsbl5@1{{yiIiXbHIc9pBx3u>sN0Q^Zxt#Uhkyl~bTIu3A=^aj1 zCXS7Yt4Qcbim14;+E^)&HQ#l{7fjK7c77m>AwhGcp+nr$QKE^vEz^EJ`&HsdN%cfi zhGXBZLHpQGW5pFp@|;0w=g>grhJs%`+=Qwe%f6_OmLppmB(JfTbg{0b4XyPVsi-Gg zRH@lf^F4H-t{u^rgn*njF0HS%jQjKX!jwr*9E%lod^vKC**KrztdI-Yuem?QdRr%L zf`Qe$Ag6t#TEI!@Kp>m<ej+4q&c{dE2>gj3;{Xm1f6Kkqe8%~2_LP>Iyw0Rv7m_He z`?k5W`ovGzs=GGK*TD^t$mJ(L8f~wsm9AM#Q20IEu!*dcQh#6;hfi;P7cIh*SBNG_ zV`sNL^66guS`^=58$A9QIi)TmUCrB?)!I%MR;5ZlVs{pSB>N-KYVGIji%zmqoe9f^ z_Kk^(Vn@b+R84=6Li;b!^5Z619`Y8VJ*$62>XXefFU?D2KuX!ndNQ}~nn%#cg-!v3 z9J9Us$2a(^CmJ4Xq;l^YZ{=-Pl;VQPo|)5g-|s02Am6u{j^Zw@@1)faQh*SlylHyC ztj=xPwtp&7d;ZSEm4_Yjo0w)C2k>s<T(9#RE%<HZc#<5~<DHcD9=1C9p@g!Uyo0C% zYvWMfg1!Y;?gA{^SsjY9n#4hyl;Y(;-r|l89<f7Sq_fH#N~(uDjcy8#{W78A{<#jd zT!7x>soJ7rR+Np&?NykuulGxk7J99Cj5IvavP<wldreU~*YWi<LqA(K#Th$hl|EiE zKg|gn#*ZxbSvzj7c*@s|+3QV|5A(89lpN<UEiqJj?PFh)M}CyvzbEjWZ_z*{Wl5Po zY6G9z;tt6+CHa;4@0>u22C-)zkx2}39=sJ0sJIcm=HIn~aaA?2KTXdXG=@prx1rpr zK~KKB{%qfiWX%ja!mKjuUF}1x)`Se8P4K#|PtTJ~jpWB;#USAGr&B`y&b(WAAs_C= z=FEhJE<XYNlHF1-Rhg;aPz$jp%s-NdvJG+P50gUJ++M*3PpS*q!;O%^fm}GgXT*~< z1VkWl_5R9Xf)ak>PsguI)uY<tBd_@FhnopPVC)6NxesEKmin0-*%kLE*X5*n60N1I z)C-n4TEI8WZPU@udvUATBRHV?Nb5yNKL3?+)`>%NdLU}C9GuRIekveq^<-eAmXCg_ zZFEM)_QiT)D239T4yhXzrIONbjZe<x#mnbzDJ!ehm@$-dq|X+8Jn}uO|B_Aj4Z#0k z$o8G2qKoX})HUTTCVPK32D;0jeVb>&q}BCkR0}2@+83YaThaj<bwX%G#JsD|bpAz7 zT*#cQUE53f?vM`M9xD}xbFns9FMwS1v;f^vD?<!(DL-cWSNF9;WnO4?WI$=oC@0qI z@8SUjNm$LdIJ;A?YUS;Bs{Z#VYjCq{&F0r&SC*#EVC#P25d3&#ci^=u8Jk|xwv2br zAXoAA`sW?cH5fU_BL7nzJ98l9`kFF{c(Z7cm#19iwJ|Kz`t9^C=)`3l!CX&i(sgBg zq-6B0&L3^JNP0nXd#yL&idgaao-<>b-(bPiGN_bin_%K#$?j~?FcwE_83S=#>r+FQ zFYSJFm)x7NXMja->h#2L6&X3XUNRY@u(FZBW?US%8W@RS%%;^jh792XdKpJLb=s*t zFPJYsvH1J;`!AhuxL{}{OHNPG^T1e5ktRSc^IqQs^`V>%dXY39Yt8OY1n05s1bK<) zn<S%gwko)$b}Za2!9lKjeC$OW#aG&iBDxX}LKBEmMNDY5qJHEejG&_tzGzU8M?9V} ztv|A0VlL{X)hHftPsr~U3+CA==w0*k-gbMl+&B}{<0xE-Cq)RviC^#?vM0M~S3&(} zin0j-b72x=BCWkmB#czD{4=6(F?twMv$`ys_%yZ^oo#LkOw)X*zM30(QTullt>kkO z;gp9yeUN@E<KJ&pAClv6&=yv^Yh+Uy_7BEYaj86*VIm)A7P1|NFclm@G7Vbp<_X{A z-ral$1k#X5?hJjkp)nhm-7cVnyT@$hDB*k%BI6tnEKRpAVRZ7(M>C86c6T4tk%G-f zPb55?R+S@SzY*87e4K~40Di9rQ~zQqw5oRBS!u!kaBEj{^NtAR?D*ig@6}ldw(Chc zx4G*rB)u2w9)LjaANg~(+E`*MCPe!HbrwK<XLRrSlpW3u#qaf{$4$6$8Lv8bI1Kx4 zO<k7QoB*fZp{;CK_Oh;`gv=FK@(CyspHoIMZnBmaTaC)?%%gCir3!0-F$S<yVdllT zhTKcn^UP&y<fbU&M+T7GwFk|keIM3}D_GR`T}UyhfG}1GjZ+rAg3S~iR+P}diXju* zv7O^YVXz5p#QEf>q9{V(W+Og@70|k*{-8g30gkl%-m}ZR6@H_SMuXNT&Tpxz?;LVq zH1M%qv6yG?C`m5D4`Mou2xM9<B96B)VV9Z9!&f{W<GHI5W@gZqsZzOB&O&;W(%i?> zP_I9<s_s9diY=Lb2;Nl-L<XS~KNzZdS6_)l#j_{%cFg3umQ6avbX{gN9T2L>Xxvs` zglrMT*<p4`f1Rbkig(wm)1b$`hl=CBCO&}rusKi>0#f~2|MSwSfqjhYL$iq)2Fq9G zm1lSy?D(i=j05!%!mty_w0-uW`g`1{M+YS#9K%s{i8=S=*>~@X7)qevTOdvGIxHH( z&N-SLpd;@ft}8`jmFj`_%f7E_#U59oMfZ9P4q;#)Wo;gh1scsuIn`NXu7E!MgYEhp z|3w{%TEncZ{+z3#V^~ffd#_*K&Rj7nd1i7s*VWEE1>vLue5GgXVNhQZKZSh4M<&UX z?>0*97+}1R&S7a7+h1cNcbphFb55XfB|Om&(O<F|1bp~-XGne+WI_!EFGNyk8we^7 z#qExg9LGw?pM~(FzcM8r6PE3p5hloLDacc@^zNZVJo9lWg1ZuR-Yvje3^u^of}Cz5 zlP>fKyI0J}06M67*yPWD6Y8PYIkm`>7%`~$af{<W-QL!=rBv{S$J1P}I5}Rrt@qFl z*(rU5!g#{Z%kS=Sa}}CZyEeH&crL&v#OwK(-#$NwM8?^AE%o|?&x8ekjo;1vA+#W- zP+V1K<Q8{7R1PiYZiiA~iYq&tm^kNjqn`=f&gK_DJWbEUqVL!(ZEF@^QLnv_B+(AF z?{kdM=y14rzrHO;LVZq3tm+DuJ!jGQVTSrGv~9ufX7laK(;?1b?{=spsdJ&3N!#Ok zDT$qefZG%EY+}q2KL*t=A*@$oNuqW=-bt;wm64Y(F%q1XaLs$c`!B)HOHP$)S0+rv z1qt`!d1|P)Q!EJ1<rBlax3`7;?hR1EvsAI?Opm`_BR-O(X<sdoUQDFmy@<BsMGIDY zndwFS^mf+&#izl9#ki5(NG1dR2LHQ?a4Oy6RJd~81`Rp+6$F=EeD)eK1cXOjE<09V zg>e<_C-F;03aNQ-;1w2MCuNw=n~vIzq9ij!-xy*sUID2d7o{GlitsZETAjhx;#9DR z9!4zIVWVjGeFd6J5qFA?`XV0EFC1j-yMEP}UfIg;n=WDqr_q(anlel)I<G>qIqhzf zx!X+UHX)IUC!?Ww_I4Sv1J^YZV1J#iR1a(G;^M6L0ma=%IaqS{#Q6t(V*F&c3Wa!y z6aq(ha)k$hMNt#8N9dUsG&_19HIw_!l=8>ht%>P@2$;V_bLGrarJEp)olOg=ImqqF zY1MFJWfFGlAVQ}imgz*v%i8dz(?GJ&BZ$xVhIqzGb2AMw1;RCIh_YosjYLfS)XPwR z!-)nNO!Y|<n~@kjh~4wlmnW~+q|#Uh)Ima0;iFoqv^$7N=&*ZN#T+=toN9p%C~@!& z-8&{`LlNnH;AzmF&r4s^qKb>7B=z;+z29EmPh%GG$p&JS@!X2kaFT$Aii9flNcsxL zwi<tj>d?NJAayki%m}kUz=tIE$8^CIY!}j2jK%K@3w=k9j{EbobpCI6Q$jdT=XH=r zRWs{UKU-V`fSG>IO}{IC-@88S+vqdMTN<Y9q9NqKZ{pfB>kjI^N1S)CgB({&X&7x! z)N@)rF<TO)Oq~+o7$s-~SBo>jZ2Qww(S2HDBqlS=Sc)8S5tQYHq0KZy^6Ml~BwzCn zuB7LTn}b$mf1vMppM9VKg&@0Ry|luiW;DO5bi<>tw!5dRCq>f}8=vc<?<uF5PE%BX zwiVqF_QF83MTSyZdm!;r-zmJ_@-wI~*Y(H|1Y=Sles=G|TDSB)jzK3&-U*$S5>vZO zHTzom;%t3b6-s)2Ha2M3<4Cs`Lt>M&2`RzrW6?6l?qQ}rUM%cwevx}e?W_#nJ&fAQ zyRDsNTkxEH@oz<jA6-n`Sn!xYSO$ZkG~-LbC(Zg6T{W_uCr+fbh*O<Pfw{@7L8N7# z?CeaEFfcrLhiu?%kWn&Ap^C-Wi%4~C^=m&Y6rW%xAMCh1i0O#kC3L_w^m3^(=XNYA zln*|k4@GpohK8KV{j)lNh+bIy4WS#$`!p3Y`z}@Cjmwy`nyq$QZ%2oI(-&R92*GKi zWz_4lTz#kV#i@lf7JBQ?!8jQT*_%ki?B>$0`H{Gzmb2Iow2|0VB9jhf5J+>MyJzrG zIFyEg1P2<hh>%6_Q=G^@g2=Gww|7A#MhG9DBEjUKkK)FhqWsXhNkb5yU<{)na5bi% zi+m~(X)ZhU`ODNjy$N)B7VYH<QUhkrpaj7mAmx8uM>k2vQYAW$Fv@uPjIpvgf;<$- zBD{JbwJa(bgj1ng$cn~w93kIL+=%bGFg$iE>@3h+v5Mw0Ksf4Yg<BSGP3XGJbequM z!3BM$A0bR`5J~vL1S8Z+?vdb=78I>H1E1e{M@YPfzcWc+yFRILBKpDBk{Zgau@Wdb z5}<P4+<f-sljTvK&MFS86=i90x6%)lCGpz5Xm{kvEqw~*UMKyJ0(Y`S&vISUxb|Yb zsAooZergMZFqnpy+-5@a!k5YXTo^4_-!hD|^h%%iCgNB4KZ_c8L{ffyvCMVNULlf2 zOSd%+o(=dyMV`kYugra;bpLXbe*7wskcSQbrk4d0Z>w`j6$S;0hU^BB8D8Vw<`$nl z_K>1FCtIHyJnB_M#2{Zl&xaPh6I5w9W)eGkpR50H9?zGS31U-TMl$`8+IihC%YVA= zp@0)hn67^aK?4qkmPoGcpiau4%Vt%{I<>BjrT3!-?dz4oS0E2bdt)DsAY-<rVCw!v z;o*vpP`)3iFP>;$7oYeL*ahV(a(na0VDk%5FTAmPVjYUyJ>$PWKE5+#exvuvM2;9) z?Vc>SfXOmmi)#$Za9;6jyou;~eSED0d*Ys8j{GyJ%NlD;!%#N{)2g4s;q*n_gNemX z3E?huC@vRXGPbIpF{SD?+|X7rMAno1o-WFflZGB!G-3*4in~QHEq~JpLSp7O$}=&m zH+?w#L)Dy3{}`!xX2GY^dEZQA@epnnn06&VZLDwg;wQqCGJ%|x@I>w+kuYL$khPO? zC@Y{pBXkK5QnFGm)aN~{Yh^Orv99q^3HMkbg*b0&vre+nu1o5uP^dIR`ATHD7)il{ z+;GoVJewXIxeI>Z8dTxTDOs!Zu-;y(KEcJQ*ZUX5{CpIDk$ZyEAgNMh*+FBS=&*77 z4@-@So_9Rlef=a=GZe$$g;2GuMmFW0!m&#T_|(TD&f9`Ukq)6XNGa?P{9BETDKbwE z(K4q?bHlVN@gm%=>eK<O?zCUQwG?UU1%*~r!zFm0B9afjoH{g@675)sHfSZ@WuKO~ zWdTFgc`T-ayrO{5o1Lne$lGYx<4piThK5}I$nXe3<&wtM6y&sqv8yz>0A*{NK0$4+ zR8BQ{xpR0_V@D})iLAt6>2UC}@pUn=1w@#ZFtt!ujH;_$l-T{OoY+nB&B80uXxY<a zS=>_CC~u2S79IMGgjjT!z#N31{vzMBE14)Qq}M@?KzW9B{Ah*&m44cb&`+2~%kFZ` z4Rg91x0&_U*o<L4M8y6d<?<6b+O0Zw;q?Fln#GmG%z01`fr71?XNu=kkcZ>r{JezE zjQa@!OJgU^C`~=T9gL`A>Fuz#4}wm2n7W&hp80eIS>O4^wvmQ3+YOy*;?+^JykT6e zE(*^}NyN?U%j4BR*I*p_t+XXaeVwZizr;FWlKorU5`u{^AA!P&;X6vb;$0i^^CYL$ zOw@S5b|qU^T9uM+xsC8FH-DF#<0~W+xn+liS@+M{MRyLJ?`%!=G|en+gM@(&DS2Bb z5s)|pKdQz&9RhF&UeX*e(G=`GYYWYbl!=FKU0Fwg!IdS1b79{MoMgxnSyQRYBNPu& zoYV5@OyWA72G!$av^at_`!;v{i$wtnSB-G}kZUY~7E+~V)D-~ynPZn3yI`>^7K6Yx zPlT>YjIlJ}s#Sfo@9$s0!^$(xi{Y>`jynxaM#aF15of){OW)s9@A41GVCABP%XU6f zV_D-%L&%)6;rAO&E965|Id5lcrf!wdBvOhqcP7+fL_)ZIuBypYEvztdORrL0J@-g< z81!AJ<3Ie4&LmxU7`Qy6V|iaWV&lRSz!jW+@Q}%~QnztqXng(%ji=G#xjybl3HK|J zn{k5l>rPhNgkSo4>+ixqr#shb1nH`Myz&LM`OQUuD!e$Wv$vjF5LYy(A}wLQaQ|-4 z&GWlJ_bHq$rok=0P?0x1v#;C+fh|RAmTg(xmf1zgoFU9R<3+nhNK8YpA3CS2DpV5L z6Pup)tG<oJGN25bvKqq~j4&_r`7w9<U<HifaArT_BkSEu-Qp-BTo+y`Ke-iD$gZz` zh6??Z>}VH<hwQ(BBqE|UyJZL5*py%iS7LJnY68!G*l&mSBI*EZ?C3zi-Pq;r0T1b} zLBGOlb<s!(r!Lz2<k1=4=bXBn?IcvgK$t@jL*StBl!MbVCgVB5*U@4m*FdZzEB_qE zrhz;dop~-Ti<*Zj?vEK7WBt_TaeO<S&=m2c6&GYofgTAmmBz<FIm>kFJbD9MgE>ol zgM_&XQd>6adNEkfiZTWq93J=2_j&d7rYh^DvO&otVnn*(9>de|t_?A#MG0d=`j6cR zjAS);9b<hPk`dxv95qX{SfPWX?Z6j=`1}h(RMo5wZ$5Y0OpA5O=C(oMFO!i{(_sQM z(ddCPF>ub=%!jx4+EDL1uR#Q9uZnBsG4MzIO??Tlgj>c=GVrWNtH1S_IZ@@K&)2E` zm8ayb1GQ&SequO=GEt<d$RGzsPyI9^moaF}0jej~3soJ<h!@l+>F?MD8I|BW$=b@s zORczE=a_|#+96&4EzmS$s#hFo+MpURb3XlkoHG9KR7Cz2IS!a71S=>uyRm~*LK>E= zw?+lhUiVTq^BN-R!o#m|q0gFcTI7BXKs?@SO<In663omT-S)s2$%9WD<sx$5bK)Yg zP&nIe2AppnqBK}#IeY*tC}ZC0`@ZEMu@M#mArBmnc_~HOy`+ZG)@IuLj)E^4ZFSq( zAqgyVBrzlBbw@(EuU5aDBydi$lUqF!>|#e&?a5suXRPbz7<W8phHrwO50JY;VTZan zpc3?uCw>_i#0i-&!ey&k)_r|Yn?!u(=c$bf&>*->#d$OvbhiBRa*tEiQPOc1SoT=c zI7D&GOwaj2uLnGG_F#Y%ScJa5l+jIF0f*LjlL#Z;H08BD2U{AiZY^80Ex9`c7M0=b z=WO}V-%J>}vXlaWNBE7zR!s{>49@<e$1W!x`vNUih(K=_kietFE`AV>1{iLCyo#~S z;kRO1^qJg8+hqC({X0uAnLH%5?{Y<pZz<Mkb~Wl>6|_)K$1f@Y#yF`lHxo6ce8Oeu zEpGX^CMz>Pd8!0g>(OMBm<tA`mT}#CytpPnZa~frV;HYxm==EW)c5%!vW}%3dIAom zk~Yn!z)CYhsW@*%VedtrxCG7h#5im-<{6lWpFd3{+f>2_YI$kG`J`P`^C?89<z!B+ zq<e1r!O$fSpaSL*S3BE4P8ZC1iRX>iM;55ex~@Eit#@-_vlQbc6iz;o4<I^<0-#g6 z@6kXyd1}^(%HsDO+oCh_oc+E%bUs6ku*x-|Q{?)Bm@qf5QkNQLS_8pnd`^$NHOQ$z zRx0V|lX`nT1FH_$%;92F(5ZhT;<M`etyAoVH-K~pUe}7po5+veb43HF>B)a|jsErR z`|!WJMovbK7WSb3pR4yZ<G#oG|L#I-{_aBmMNpEKl#%&2-KJ=jk(gyMbnrDj!5w)M z*^mPX?mJI(7vf&wI_8R7UcVYY(@+LSfMZBHzLa67;4G11Z1=l6K*IGw*-@44m}&iJ z*;m~6E=11w1iP+mv;9+#!2R3~i+l$ck@Ap6h2+OjC#mOt9OVXTvn5`+T4RsfMZPC< z!>)^4xwdV6#1TPozS+LZj=LRX{@9_FK5vrs;fCy|Tv`V~@J5-Hkx510e32ypGLuYI zU@ZA(A$r!iecb*cGH>0yTKfpr(CoOfN(zE0P}Wb`O9>Q+N++u@{%T9k=%O?=4vPg? z{!smL4fFJ6N_hJg=8kLMb$OV$?&KxYoV7JMZa`uLk;@8NPlo!2b|7-mML<HibAy|X z#>9!0CG&^krZV=Rx@HcR{JxwWzujW}EYX^dEjY_e==NvqxcRr`gxfE|LJL1VzKu8f zR6q*1MU<*a07A3JcvmrT&`>u>i#F8MJ$d5neMqRzKF8MI46a#6t9AtY(Ng&_S2svt zZ3oi|c$zr#_#i0S(1k!Fp=zC5Y91>MUg(w1Ymr@!@JxJI4WvW-fOTOqtxWr4$$f$s zFdMw!hrI!X6LeLNXwR+daa+u+(|f~5in39)QQnY}>wB6<s-B9IPwx>_bd~tPv|aiB zX{!7}Wi23%ebJe`maH}rM$SKZjv-+oe)+B^C8y+)v2B4vvA<Wp&A7kQ*f1o{gze&4 zo(nNGe-cy;7P@>MJLC+z^4wR^3r#Nbg}=ciGHlKGC|m@%N6FRE+5QxFv+Ip3U!XtK zkB?N}x#`Z5qxicmcuA!0uJdIRSYAk^+^oWm0#>EPW5y)S7^b3o7ykb1NN#ki69Jf? z2tSlAB3Kl<>53<7T*4y+5z^bqsXiUkXJBA#?=%S#MD{q5Jk7_`@C8Xp8SIq+1;9^< z6X3@|GESUdkn~c8EzA=tUKRoWe5C$}+`68j4eFU|tSvz&RYCD)1`#UuaN%Ozt%f*K z;C#vujTS$hj6@L6r|9*yhcDY8G1eef#vPBJ%aLvYk$)lpg-6Q~+HX|yOtlg#UY>K) zfs}k));9uhQDcXUMbNsv-nOkXB{<VfV@o$~z2H;4o^;No!X`J|<!GX>BVqCKGcyj~ zJSvI<tH#LZzAB%METQ@93Nle{bd*hBNLLXAMg^WePgki0Po7&JCA0JHzM)Se7yZKh zOGxssg8<y`Eo|WAWb$ugz&l71sDF(>g24Mf^E}WYPDTED{bQyF%s*y&{6F(N{sR6_ z6FvR`{5|^vqR{{IpTIxod;DkcKZV7AhZA!DVeQ{##{U`mPeJ0}(SrPcp#LdP{LjFD zs(t<r=Ka0Ke_P@IuKoGX@PEn&{*IUUz2JYt|6eh||Hl2-jsgFNWBBMn{4L%5Z?u1U z#h=OM?^bsIru{SZ{BN{>Z5!MlwgnnN{BsxlPcRtRzkD0v_XGJm|MmU;1Ono}0QWFa AasU7T literal 0 HcmV?d00001 diff --git a/sketchspark-author/SKILL.md b/sketchspark-author/SKILL.md new file mode 100644 index 000000000..566060e4c --- /dev/null +++ b/sketchspark-author/SKILL.md @@ -0,0 +1,31 @@ +--- +name: sketchspark-author +description: Specialized authoring guide for the "Pro Git for UX Designers" book revision. Use when writing, editing, or outlining chapters for the SketchSpark storyline. +--- + +# SketchSpark Authoring Skill + +Use this skill to author high-quality, consistent content for the "Pro Git for UX Designers" revision. + +## Authoring Workflow + +1. **Context Alignment:** Identify the target chapter and its storyline goals in [storyline.md](references/storyline.md). +2. **Voice Check:** Ensure your writing style matches the [Voice and Tone Guide](references/voice.md). +3. **Convention Verification:** Use character names, branch names, and milestones from [conventions.md](references/conventions.md). +4. **Content Tagging:** Apply the correct tag to each section based on the [Content Type Lexicon](references/lexicon.md). +5. **Technical Validation:** Reference the [SketchSpark Product Spec](references/spec.md) for technical accuracy of the AI prototyping workflow. + +## Guidelines + +- **Empathetic Narration:** Focus on Nora and Sam's journey. Relate Git commands to design pain points (e.g., losing research, managing multiple layout explorations). +- **AsciiDoc Formatting:** Use standard AsciiDoc for sections (`==`, `===`, `====`), source blocks (`[source,bash]`), and tags (`tag::type[]`). +- **Simulated Commands:** When providing terminal examples, use the `sketchspark/` directory structure. +- **Commit Messages:** Always use the `[Phase: Component]` prefix convention. + +## Detailed References + +- **[storyline.md](references/storyline.md)**: The 10-chapter narrative arc. +- **[spec.md](references/spec.md)**: Product details for SketchSpark. +- **[lexicon.md](references/lexicon.md)**: Tag definitions for sections. +- **[conventions.md](references/conventions.md)**: Naming standards. +- **[voice.md](references/voice.md)**: Persona and style guidance. diff --git a/sketchspark-author/references/conventions.md b/sketchspark-author/references/conventions.md new file mode 100644 index 000000000..e933ca071 --- /dev/null +++ b/sketchspark-author/references/conventions.md @@ -0,0 +1,56 @@ +# Cross-Chapter Conventions + +This document ensures consistency across the entire book. All walkthroughs and prose must adhere to these facts. + +## The SketchSpark Team +- **Nora:** UX Lead (CLI user) +- **Sam:** UI Designer (VS Code user) +- **Priya:** Illustrator (GitHub Desktop user) +- **Kai:** Frontend/ML Engineer (JetBrains user) +- **Marcus:** Community Contributor (fork-and-PR workflow) + +## Repository Structure +The repo name is always `sketchspark`. +``` +sketchspark/ +├── product-brief.md +├── research/ +├── concept/ +├── screens/ +├── illustrations/ +├── icons/ +├── design-tokens.json +├── pipeline/ +├── docs/ +├── CONTRIBUTING.md +├── CHANGELOG.md +├── .gitignore +└── .gitattributes +``` + +## Milestone Tags +- `v0.1-concept`: Concept approved, wireframes in place. +- `v0.5-alpha`: End-to-end pipeline working (web). +- `v0.8-beta`: Multi-platform, design token integration. +- `v1.0`: Public launch, refinement editor. + +## Standard Branch Names +- `main`: The stable version of the truth. +- `option/<name>`: Design explorations (e.g., `option/card-layout`). +- `feature/<name>`: Approved work (e.g., `feature/onboarding-illustrations`). +- `fix/<name>`: Corrections (e.g., `fix/contrast-audit`). +- `research/<name>`: Discovery work. + +## Commit Message Format +The team uses a `[Phase: Component]` prefix: +- `[Design: Results Screen] Add overlay diff comparison mode` +- `[Research: Persona] Update early-adopter goals` +- `[Pipeline: Prompts] Improve mobile layout generation` +- `[Fix: Onboarding] Correct tablet breakpoint` + +## Key File Ownership +- `product-brief.md`, `research/`: Owned by Nora. +- `screens/`, `design-tokens.json`: Owned by Sam. +- `illustrations/`, `icons/`: Owned by Priya. +- `pipeline/`: Owned by Kai. +- `prompts/`: Edited by Kai and Marcus. diff --git a/sketchspark-author/references/lexicon.md b/sketchspark-author/references/lexicon.md new file mode 100644 index 000000000..046c4b203 --- /dev/null +++ b/sketchspark-author/references/lexicon.md @@ -0,0 +1,28 @@ +# Content Type Lexicon + +This lexicon defines the content type tags used across all chapter TOC files. +Each sub-section is tagged to describe the **primary kind of content** it delivers. + +## Content Types + +| Tag | Meaning | +|--------------|---------------------------------------------------------------------------------------------| +| `concept` | Explains an idea, model, or theory. Answers "what is this?" or "how does this work?" | +| `walkthrough`| Step-by-step narrative that guides the reader through a realistic scenario or workflow | +| `procedure` | Task-oriented instructions: do X, then Y, then Z. Answers "how do I do this?" | +| `reference` | Lookup-oriented listing of options, flags, commands, or settings | +| `history` | Historical narrative or background context about origins and evolution | +| `comparison` | Evaluates alternatives side-by-side, including pros/cons and trade-offs | +| `diagram` | Primarily visual — uses diagrams or figures to explain a model or data structure | +| `recipe` | Short, self-contained example showing a specific technique or tip | +| `config` | Configuration-focused: editing config files, setting options, customizing behavior | +| `internals` | Deep dive into underlying mechanisms, data structures, or protocols | +| `overview` | Brief orientation or survey — introduces a topic area without going deep | +| `integration`| Covers connecting Git with external tools, services, or platforms | + +## Usage Rules + +1. Every sub-section (`====` level) and leaf section (`===` with no children) gets exactly one tag. +2. Parent sections (`===` with children) do **not** get tagged — the children carry the type. +3. When a section blends types, choose the **dominant** one (>50% of content). +4. `Summary` sections at chapter end are tagged `overview` (they recap, not introduce). diff --git a/sketchspark-author/references/spec.md b/sketchspark-author/references/spec.md new file mode 100644 index 000000000..075d9a515 --- /dev/null +++ b/sketchspark-author/references/spec.md @@ -0,0 +1,298 @@ +# SketchSpark — Product Specification + +## What Is SketchSpark? + +SketchSpark is an AI-powered rapid prototyping application that turns rough sketches into polished UI designs. A designer provides a single input — a napkin wireframe, a whiteboard photo, a tablet drawing, or a simple digital sketch — and SketchSpark generates up to five distinct, high-fidelity UI options in parallel. The designer reviews, compares, selects a direction, and refines it iteratively until the design is ready for development handoff. + +--- + +## The Problem + +The gap between idea and testable prototype is the slowest part of the design process. A designer has a concept — maybe sketched on paper during a meeting, maybe roughed out on a tablet on the train home — and turning that into something a team can evaluate takes hours or days. Wireframing tools require manual construction of every element. High-fidelity mockup tools demand pixel-level precision before anything looks real enough to test. + +Meanwhile, the best design decisions come from comparing options. Research consistently shows that teams who evaluate multiple directions produce stronger outcomes than teams who refine a single idea. But generating multiple polished directions multiplies the time cost — so in practice, most teams explore one direction and hope it's the right one. + +SketchSpark eliminates this tradeoff. + +--- + +## Core Interaction Model + +### Input +The designer provides a rough sketch through one of three input methods: + +1. **Upload**: Photograph of a hand-drawn sketch (napkin, whiteboard, notebook), uploaded as JPEG or PNG +2. **Draw**: Freehand sketch drawn directly in the SketchSpark canvas using a mouse, trackpad, or stylus +3. **Import**: Existing low-fidelity wireframe imported from Figma, Sketch, or as SVG/PNG + +The sketch does not need to be precise. SketchSpark interprets intent: a rectangle becomes a card, a circle becomes an avatar, a squiggle with lines becomes a text block, an arrow becomes navigation. The AI model is trained to read rough spatial relationships and structural patterns, not pixel-perfect drawings. + +### Processing +SketchSpark analyzes the sketch and generates up to five UI interpretations simultaneously. Each option: + +- Applies a different layout strategy (grid, list, asymmetric, card-based, editorial) +- Respects the spatial relationships in the original sketch +- Uses the project's design tokens (colors, typography, spacing) if configured +- Follows platform conventions (iOS, Android, or web) based on project settings +- Meets WCAG AA accessibility standards by default (contrast, touch targets, font sizes) + +Generation takes 15–45 seconds depending on sketch complexity and selected platform. + +### Output +The results screen presents all generated options in a side-by-side comparison view. For each option, the designer sees: + +- A full-fidelity screen mockup at the target resolution +- A confidence score (how closely the option matches the sketch's intent) +- Layout strategy label (e.g., "Card Grid," "Editorial Stack," "Split Panel") +- Quick annotations highlighting key interpretation decisions + +The designer can: + +- **Select** an option to use as the starting point for refinement +- **Compare** two options in an overlay diff view (superimposed at 50% opacity) +- **Regenerate** a single option with adjusted parameters (e.g., "more whitespace," "larger typography") +- **Refine** the selected option in an integrated editor with AI-assisted adjustments +- **Export** any option as Figma file, SVG, PNG, or development-ready code (HTML/CSS or React components) + +### Iteration +After selecting a direction, the designer enters the refinement loop: + +1. Adjust the selected design (move elements, change hierarchy, update content) +2. Ask SketchSpark to regenerate variations of the adjusted design +3. Compare, select, adjust again +4. Repeat until satisfied + +Each iteration takes seconds, not hours. The designer maintains creative control — SketchSpark generates options, the designer makes decisions. + +--- + +## Product Architecture + +### Core Screens + +| Screen | Purpose | Key Interactions | +|--------|---------|------------------| +| **Home / Dashboard** | Project list, recent sketches, quick-start | Create new project, open recent, view history | +| **Sketch Input** | Upload, draw, or import the source sketch | Drag-and-drop upload, freehand canvas, file picker, Figma import | +| **Generation Progress** | Loading state during AI processing | Progress indicator, cancel button, "What's happening" explainer | +| **Results Comparison** | Side-by-side view of 5 generated options | Select, compare overlay, regenerate single, expand detail | +| **Refinement Editor** | Edit selected option with AI assistance | Direct manipulation, AI regeneration of subsections, token application | +| **Export** | Output to design tools or development formats | Figma, Sketch, SVG, PNG, HTML/CSS, React components | +| **History** | Version timeline of all generations and refinements | Browse, restore, branch from any point | +| **Settings** | Project configuration | Platform target, design tokens, team preferences, API keys | +| **Onboarding** | First-run experience for new users | 3-step tutorial: upload → generate → refine | + +### Platform Targets +SketchSpark generates designs for three platforms: + +- **Web** (responsive: desktop 1440px, tablet 768px, mobile 375px) +- **iOS** (iPhone 15 Pro, iPad Pro) +- **Android** (Pixel 8, Galaxy Tab) + +Platform selection affects layout conventions, navigation patterns, typography scales, and touch target sizes. A single sketch can generate options for multiple platforms simultaneously. + +### Design Token Integration +Projects can define design tokens (via `design-tokens.json`) that constrain generation: + +```json +{ + "colors": { + "primary": "#2563EB", + "secondary": "#7C3AED", + "surface": "#FFFFFF", + "on-surface": "#1E293B", + "error": "#DC2626", + "success": "#16A34A" + }, + "typography": { + "heading-1": { "family": "Inter", "weight": 700, "size": "32px", "line-height": 1.2 }, + "heading-2": { "family": "Inter", "weight": 600, "size": "24px", "line-height": 1.3 }, + "body": { "family": "Inter", "weight": 400, "size": "16px", "line-height": 1.5 }, + "caption": { "family": "Inter", "weight": 400, "size": "12px", "line-height": 1.4 } + }, + "spacing": { + "xs": "4px", + "sm": "8px", + "md": "16px", + "lg": "24px", + "xl": "32px", + "2xl": "48px" + }, + "border-radius": { + "sm": "4px", + "md": "8px", + "lg": "16px", + "full": "9999px" + } +} +``` + +When tokens are configured, all generated options use them — ensuring brand consistency across every variation. When tokens are absent, SketchSpark applies sensible defaults. + +--- + +## AI Generation Pipeline + +### Sketch Interpretation +The input sketch passes through a vision model that identifies: + +- **Elements**: rectangles (cards, containers), circles (avatars, icons), lines (dividers, borders), text blocks, arrows (navigation, flow), images (placeholders) +- **Hierarchy**: relative size indicates importance; vertical position indicates reading order +- **Grouping**: proximity and alignment suggest related elements +- **Intent patterns**: recognized UI conventions (tab bar, header, list, form, modal) + +### Option Generation +Each of the five options is generated by the same base model with different layout strategy parameters: + +| Option | Strategy | Characteristics | +|--------|----------|-----------------| +| Option 1 | **Faithful** | Closest interpretation of the sketch's literal layout | +| Option 2 | **Grid** | Elements reorganized into a structured grid system | +| Option 3 | **Editorial** | Asymmetric, magazine-style layout with visual hierarchy emphasis | +| Option 4 | **Minimal** | Maximum whitespace, reduced elements, focus on core content | +| Option 5 | **Dense** | Information-rich, compact layout maximizing content density | + +The strategies are configurable. Teams can replace defaults or add custom strategies via prompt templates (`prompts/sketch-to-ui.txt`, `prompts/mobile-layout.txt`). + +### Prompt Templates +The generation pipeline uses text-based prompt templates that define how the model interprets and renders sketches: + +``` +# prompts/sketch-to-ui.txt +# Core generation prompt for SketchSpark + +## System Context +You are a UI design generator. Given a sketch analysis (element positions, +hierarchy, grouping, intent patterns), generate a high-fidelity UI mockup. + +## Constraints +- Apply design tokens if provided; use system defaults otherwise +- Meet WCAG AA contrast ratios (4.5:1 for body text, 3:1 for large text) +- Touch targets minimum 44x44px for mobile, 24x24px for web +- Respect platform conventions for navigation, typography, and spacing + +## Layout Strategy: {strategy_name} +{strategy_description} + +## Output +Render as structured layout definition with element positions, styles, +and content. Include accessibility labels for all interactive elements. +``` + +These templates are plain text files — fully version-controllable, diffable, and improvable via pull requests (as Marcus demonstrates in Chapter 6). + +### Accessibility +Every generated option includes: + +- WCAG AA contrast compliance (checked automatically, violations flagged) +- Semantic structure (headings, landmarks, reading order) +- Touch target sizing per platform guidelines +- Alt text suggestions for image placeholders +- Focus order and keyboard navigation hints + +An optional post-generation accessibility audit (`prompts/accessibility-check.txt`) runs a second pass and annotates the design with specific compliance notes. + +### Model Configuration +The AI model's behavior is controlled through `model-params.yaml`: + +```yaml +model: + version: "sketchspark-v3.2" + inference: + temperature: 0.7 # Higher = more creative variation between options + max_tokens: 8192 + timeout_seconds: 45 + generation: + num_options: 5 # 1-5 parallel options + min_confidence: 0.6 # Don't show options below this confidence + platform: "web" # web | ios | android + responsive_breakpoints: + - 1440 + - 768 + - 375 + quality: + accessibility_level: "AA" # AA | AAA + contrast_check: true + touch_target_check: true +``` + +This file is structured YAML — Git can diff it, hooks can validate it, and changes are traceable through commit history. + +--- + +## User Roles and Workflows + +### Solo Designer (Freelancer) +- Uploads client sketches, generates options, presents 3–5 directions to the client +- Uses SketchSpark to compress the "sketch to mockup" phase from 2 days to 2 hours +- Exports directly to Figma for final polish and handoff + +### Design Team (3–8 people) +- Shared project with design tokens enforcing brand consistency +- Multiple designers generate options for different screens simultaneously +- Results comparison view used in team critiques — "let's look at everyone's options for the checkout flow" +- History view tracks who generated what and which directions were chosen + +### Design-Engineering Handoff +- Selected designs export as development-ready code (HTML/CSS or React components) +- Design tokens ensure generated code uses the same spacing, colors, and typography as the design +- Engineers consume tokens from `design-tokens.json` in their build system +- Version history provides context: "why does this screen look this way?" → trace back to the original sketch and the option selection decision + +--- + +## Technical Stack (for repository context) + +| Layer | Technology | Repository Artifacts | +|-------|-----------|---------------------| +| Frontend | React + TypeScript | `src/` (not in design repo) | +| Design | Figma (source), PNG/SVG (exports) | `screens/`, `illustrations/`, `icons/` | +| AI Pipeline | Python + PyTorch | `pipeline/`, `model-params.yaml`, `prompts/` | +| Design Tokens | JSON (consumed by both design and engineering) | `design-tokens.json` | +| Documentation | Markdown | `docs/`, `product-brief.md`, `research/` | +| CI/CD | GitHub Actions | `.github/workflows/` | + +The design repository (the one tracked in the book's storyline) contains everything except the frontend source code. This is intentional — the repo is a designer's workspace, not an engineering monorepo. + +--- + +## Product Milestones (as referenced in the storyline) + +| Tag | Milestone | What's Working | +|-----|-----------|----------------| +| `v0.1-concept` | Concept approved | Product brief, personas, competitive analysis, initial user flows, wireframes | +| `v0.5-alpha` | Internal alpha | End-to-end pipeline: upload sketch → generate 5 options → view comparison. Single platform (web). Default tokens only. | +| `v0.8-beta` | Public beta | All three input methods. Web + iOS platforms. Design token integration. Export to Figma and PNG. Onboarding flow. GitHub public repo. | +| `v1.0` | Public launch | All platforms. Refinement editor. Code export. Accessibility audit. Team collaboration features. Mobile prompt improvements (Marcus's contribution). QuickMock migration complete. | + +--- + +## Competitive Landscape + +| Competitor | What It Does | How SketchSpark Differs | +|-----------|-------------|------------------------| +| **Figma** | Collaborative design tool | Figma is the canvas; SketchSpark is the idea accelerator. Exports *to* Figma. | +| **Uizard** | AI screen generation from text prompts | Text-to-UI vs. sketch-to-UI. SketchSpark preserves the designer's spatial intent. | +| **Galileo AI** | AI UI generation from text descriptions | Similar AI approach but text-driven. SketchSpark starts from visual input. | +| **Framer** | Design + publish tool with AI features | Framer focuses on shipping websites. SketchSpark focuses on the exploration phase. | +| **Midjourney / DALL-E** | General image generation | Produces images, not structured UI. Can't export to Figma or generate code. No accessibility checking. | + +SketchSpark's differentiator: **parallel options from spatial input**. The designer's sketch encodes intent that text prompts can't — relative sizing, spatial grouping, reading order. Five options from one sketch means the designer explores more of the solution space in less time than any competitor allows. + +--- + +## Why This Product Works as a Book Example + +SketchSpark is designed to serve double duty as a compelling product *and* an effective Git teaching vehicle: + +1. **Parallel generation mirrors branching.** Five options from one sketch is the same mental model as five branches from one commit. The product's core concept reinforces Git's most important feature. + +2. **Full design lifecycle.** Research → concept → exploration → build → beta → launch → scale. Every phase produces different artifact types (text, binary, structured config) that teach different Git workflows. + +3. **Mixed file types.** Research briefs (merge-friendly markdown), screen mockups (binary Figma exports), AI prompts (diffable text), illustrations (large binary PNGs), tokens (structured JSON). This variety naturally teaches Git's strengths and limitations. + +4. **Team growth.** Solo (Ch1–2) → pair (Ch3) → small team (Ch5) → open source (Ch6). Each growth stage demands the exact Git workflow that chapter teaches. + +5. **AI pipeline.** Model configs, prompt templates, and training manifests are text files that benefit from version control, validation hooks, and code review — making chapters on hooks, attributes, and collaboration feel immediately relevant rather than abstract. + +6. **Real product decisions.** "Should we use card layout or list layout?" is a design decision readers can visualize. It's more engaging than "should we use tabs or spaces?" — and it naturally becomes a branch, a PR, and a merge. diff --git a/sketchspark-author/references/storyline.md b/sketchspark-author/references/storyline.md new file mode 100644 index 000000000..23215cf51 --- /dev/null +++ b/sketchspark-author/references/storyline.md @@ -0,0 +1,682 @@ +# The SketchSpark Storyline + +## The Product + +**SketchSpark** is an AI-powered rapid prototyping application. A designer uploads or draws a rough sketch — a napkin wireframe, a whiteboard photo, a tablet drawing — and SketchSpark generates up to five polished UI options in parallel. The designer reviews, compares, selects a direction, refines it, and iterates toward a shippable product. + +The product serves a gap in the design-to-development pipeline: the jump from rough idea to testable prototype is slow. SketchSpark collapses it from days to minutes. + +--- + +## The Team + +**Nora** — UX Lead and Product Owner. She came from agency work where she managed design research across dozens of client projects, all versioned as "final_v3_REAL_USE-THIS.pdf" on shared drives. She's methodical, writes thorough briefs, and sets process standards. She's the one who brings Git to the team after a catastrophic file loss. She uses the CLI. + +**Sam** — UI and Visual Designer. He's fast. He generates screen layouts the way a jazz musician improvises — quickly, instinctively, and sometimes messily. He commits too often with vague messages, works on the wrong branch, and forgets to pull before pushing. Every Git mistake a designer can make, Sam makes first. He uses VS Code. + +**Priya** — Concept Designer and Illustrator. She creates the product's visual identity: onboarding illustrations, marketing assets, icon sets, and high-fidelity mockups. Her files are large — 30MB PSDs, layered Sketch files, high-resolution PNGs. She's the team member who stress-tests Git's handling of binary files. She uses GitHub Desktop. + +**Kai** — Frontend Engineer and ML Integration Lead. He joins when the product moves from concept to build. He maintains the AI generation pipeline: model parameters, prompt templates, training data manifests. His files are structured text (YAML, JSON, plain text) that merge cleanly — the opposite of Priya's binaries. He bridges design and engineering. He uses JetBrains. + +**Marcus** — External Contributor. He appears in Chapter 6 when SketchSpark goes public beta. He's a designer in another timezone who forks the repo, improves a prompt template for mobile layouts, and submits a pull request. He represents the open-source contribution experience. + +--- + +## The Repository + +``` +sketchspark/ +├── product-brief.md # The source of truth — what are we building and why +├── research/ +│ ├── personas/ +│ │ ├── early-adopter.md # Primary persona: freelance UI designer +│ │ └── team-lead.md # Secondary persona: design team manager +│ ├── competitive-analysis.md # Landscape of existing prototyping tools +│ ├── interview-notes/ +│ │ ├── round-1-findings.md # Initial discovery interviews +│ │ └── round-2-findings.md # Post-alpha validation interviews +│ └── journey-maps/ +│ └── sketch-to-prototype.png # Current-state journey map (binary) +├── concept/ +│ ├── information-architecture.md # App structure and navigation model +│ ├── user-flows.md # Step-by-step task flows +│ └── wireframes/ +│ ├── sketch-input.png # Upload/draw screen (binary) +│ └── results-comparison.png # Side-by-side options screen (binary) +├── screens/ +│ ├── onboarding/ +│ │ ├── welcome.fig # Figma source (binary, large) +│ │ └── welcome.png # Exported preview +│ ├── sketch-input/ +│ │ ├── upload-flow.fig +│ │ └── upload-flow.png +│ └── results/ +│ ├── card-layout.fig +│ ├── card-layout.png +│ ├── list-layout.fig +│ ├── list-layout.png +│ ├── canvas-freeform.fig +│ └── canvas-freeform.png +├── illustrations/ +│ ├── onboarding/ +│ │ ├── step-1-upload.png # Large illustrated graphics (binary) +│ │ ├── step-2-generate.png +│ │ └── step-3-refine.png +│ └── marketing/ +│ └── hero-image.psd # Very large source file (binary, LFS) +├── icons/ +│ ├── navigation/ +│ │ ├── home.svg # SVG diffs as text +│ │ ├── settings.svg +│ │ └── history.svg +│ └── actions/ +│ ├── upload.svg +│ ├── generate.svg +│ └── compare.svg +├── design-tokens.json # Colors, typography, spacing — handoff to engineering +├── pipeline/ # AI generation pipeline (Kai's domain) +│ ├── model-params.yaml # Model configuration +│ ├── prompts/ +│ │ ├── sketch-to-ui.txt # Core generation prompt +│ │ ├── mobile-layout.txt # Mobile-specific prompt +│ │ └── accessibility-check.txt # Post-generation a11y validation prompt +│ └── training-data-manifest.json # References to training datasets +├── docs/ +│ ├── setup-guide.md +│ └── api-reference.md +├── CONTRIBUTING.md +├── CHANGELOG.md +├── .gitignore +└── .gitattributes +``` + +This structure ensures every chapter has realistic files to reference. Research artifacts are text-heavy (merge-friendly). Screen mockups and illustrations are binary (merge-hostile). Pipeline configs are structured text (hookable, validatable). The variety is intentional — it teaches Git's strengths and limitations simultaneously. + +--- + +## Chapter 1 — Research & Discovery + +Nora is a UX lead at a small startup. She's been running user research for a new product idea — an AI tool that turns rough sketches into polished prototypes. She has three weeks of interview notes, a competitive analysis, two persona documents, and a journey map. They live in a folder on her laptop called `sketchspark-research/`. + +One morning, her cloud sync overwrites the folder with a week-old version. Her latest interview findings, the revised competitive analysis, and the updated journey map are gone. She spends two days reconstructing what she can from memory and Slack messages. She never fully recovers the competitive analysis. + +A developer friend tells her: "This is exactly what Git solves." + +Nora installs Git. She learns what version control is — not through the history of Linux and BitKeeper, but through the pain of losing irreplaceable research. She learns that **centralized version control** is like her shared Google Drive: everyone connects to one place, and if it goes down or conflicts, work is lost. **Distributed version control** means every team member has the full history locally. If the cloud disappears tomorrow, her laptop still has everything. + +She learns the three states — modified, staged, committed — and maps them to her own workflow: +- **Modified**: she's updated the interview notes but hasn't marked them as ready +- **Staged**: she's selected which updates to bundle into a checkpoint +- **Committed**: the checkpoint is permanent — she can always come back to it + +She sets up her identity (`git config`) so her name appears on every checkpoint she creates. She asks: "Can I version my journey map PNGs and Sketch files?" The honest answer: Git handles them, but it can't show you what changed inside them the way it can with text. This limitation — binary vs. text — becomes a thread that runs through every chapter. + +--- + +## Chapter 2 — Concept Design + +Nora creates the SketchSpark repository. + +``` +cd sketchspark +git init +``` + +She adds the product brief, her persona documents, the competitive analysis, and the initial user flow. Each one is a markdown file — Git can track every word that changes. + +``` +git add product-brief.md research/personas/ research/competitive-analysis.md concept/user-flows.md +git commit -m "Add product brief, personas, competitive analysis, and initial user flows" +``` + +She learns the daily rhythm: check status, stage changes, write a commit message that explains *why* (not just *what*), review the log to see her project's history. She creates a `.gitignore` to exclude temp files her design tools generate: + +``` +.DS_Store +__MACOSX/ +*.sketch~ +*.figma_cache +Thumbs.db +``` + +She adds wireframe exports — PNGs of the sketch input screen and the results comparison screen. These are binary files. Git accepts them, but `git diff` shows nothing useful. She notes this and keeps going. + +She commits the wireframes separately from the text files — a habit she develops because text and binary changes serve different review purposes: + +``` +git add concept/wireframes/ +git commit -m "Add wireframes for sketch input and results comparison screens" +``` + +She explores the log. She uses `git log -S "5 options"` to find when she changed the product brief from "3 options" to "5 options" — tracing a design decision through history. + +She tags the milestone: + +``` +git tag -a v0.1-concept -m "Research complete, concept approved, entering UI exploration" +``` + +The concept phase is over. The product has a brief, personas, a competitive landscape, user flows, and wireframes — all versioned, all recoverable. + +--- + +## Chapter 3 — Parallel Exploration + +Sam joins the project. He's a UI designer who works fast. Nora brings him up to speed on the product brief and user flows, then asks him to explore layout directions for the results screen — the screen where users see their 5 generated options side by side. + +Sam's assignment mirrors the product itself: generate multiple options in parallel, then choose the best direction. + +He creates three branches: + +``` +git checkout -b option/card-layout +git checkout -b option/list-layout +git checkout -b option/canvas-freeform +``` + +Each branch contains a different approach to the same screen. On `option/card-layout`, the 5 options appear as cards in a grid. On `option/list-layout`, they stack vertically with detail panels. On `option/canvas-freeform`, they float on an infinite canvas the user can pan and zoom. + +While Sam explores, Nora continues refining the sketch input flow on `main`. She updates `concept/user-flows.md` to clarify the upload step. + +Sam, on `option/card-layout`, also edits `concept/user-flows.md` — he adds a "compare options" step that doesn't exist yet. Neither knows the other has touched the same file. + +Sam finishes the card layout and switches back to main: + +``` +git checkout main +git merge option/card-layout +``` + +**Conflict.** Both edited `concept/user-flows.md`. Git can't automatically reconcile Nora's upload clarification with Sam's new comparison step. They sit together, open the file, and see Git's conflict markers. They keep both changes — Nora's refined upload step *and* Sam's comparison step — in the right order. They commit the resolution. + +This is the team's first merge conflict. It's a text file, so the markers make sense. Nora notes: "If this had been a Figma file or a PSD, Git couldn't show us the conflict at all. We'd have to open both versions and manually compare." + +They establish branch naming conventions: +- `option/` — design explorations (may be discarded) +- `feature/` — approved work heading to production +- `fix/` — corrections to existing work +- `research/` — investigation branches (new interviews, usability tests) + +Mid-exploration, Nora discovers a critical flaw in the sketch input screen on `main` — the upload error state is missing. Sam is deep in `option/list-layout`. He creates a hotfix: + +``` +git stash +git checkout main +git checkout -b fix/sketch-input-upload-error +``` + +He designs the error state, commits, merges to main, then returns to his exploration: + +``` +git checkout option/list-layout +git stash pop +``` + +The team reviews all three options. They choose the card layout. Sam rebases the other two branches onto the latest main (which now includes the card layout merge) to see if any ideas from `list-layout` or `canvas-freeform` are worth carrying forward. They cherry-pick the "pinch-to-zoom on selected option" interaction from `canvas-freeform` into a new `feature/zoom-on-selection` branch. + +The exploration phase ends. One direction chosen, two archived, one idea salvaged. + +--- + +## Chapter 4 — Team Infrastructure + +The project has outgrown Nora's laptop. Sam needs access. They're about to bring on an illustrator. The repo needs a home. + +Nora evaluates options. Self-hosted Git servers are overkill for a three-person startup. GitHub offers pull request reviews, branch protection, project boards, and free private repos. GitLab has similar features but the team already has GitHub accounts. They go with GitHub. + +Nora creates the `sketchspark` organization and pushes the repo: + +``` +git remote add origin git@github.com:sketchspark/sketchspark.git +git push -u origin main +``` + +Sam needs SSH access. Nora walks him through key generation: "The `.pub` file is a badge — you give it to GitHub to prove who you are. The other file is your secret key. Never share it, never commit it." + +Nora configures branch protection on `main`: +- Pull requests required — no direct pushes +- At least one approval before merge +- Status checks must pass (they'll add these later) + +She sets up team roles: +- Nora: admin (manages settings, merges to main, handles releases) +- Sam: write (creates branches, opens PRs, pushes to feature branches) +- Stakeholders (the CEO, the lead engineer): read-only (view progress, leave comments on PRs) + +Sam opens his first pull request — the zoom-on-selection feature from the previous chapter. Nora reviews it on GitHub, leaves a comment asking for a loading state, Sam adds it, and Nora approves and merges. + +The team has infrastructure. Every change goes through review before reaching `main`. + +--- + +## Chapter 5 — Design & Build Sprint + +Two new people join. **Priya** is a concept designer and illustrator — she'll create SketchSpark's onboarding illustrations, the icon set, and high-fidelity marketing mockups. **Kai** is a frontend engineer who will build the AI generation pipeline, connecting the design work to the model that turns sketches into UI options. + +Four people. Four parallel workstreams: +- **Nora**: UX flows and research updates (text files) +- **Sam**: production UI screens for all core flows (Figma source + PNG exports) +- **Priya**: onboarding illustrations and icon set (large PNGs, SVGs, PSDs) +- **Kai**: AI pipeline configuration (YAML, prompt templates, JSON manifests) + +Each works on a feature branch: + +``` +nora: feature/ux-flows-v2 +sam: feature/production-screens +priya: feature/onboarding-illustrations +kai: feature/ai-pipeline-setup +``` + +Nora acts as integration manager. She reviews each PR before merging to `main`. The workflow: + +1. Designer creates branch, does work, pushes +2. Designer opens PR with description and screenshots +3. Nora reviews — for design work, this means checking screenshots, verifying flows, confirming token consistency +4. If approved, Nora merges to `main` + +Priya's first push takes three minutes. Her onboarding illustrations are 15-30MB each. The team discusses Git LFS but decides to revisit it later — for now, the repo is manageable. + +Sam creates `design-tokens.json` — the bridge between design and engineering. It contains colors, typography scales, spacing values, and border radii. Kai consumes these tokens in the frontend build. This file becomes one of the most frequently committed files in the repo, and the source of the most merge conflicts (everyone touches it). + +Kai sets up the `pipeline/` directory: `model-params.yaml` defines the AI model configuration, `prompts/sketch-to-ui.txt` is the core generation prompt, and `training-data-manifest.json` references the datasets. These are all text files — they diff cleanly, merge predictably, and can be validated with hooks. + +The sprint converges. The sketch-to-options pipeline works end to end for the first time: a user draws something, the model generates 5 UI options, and they appear in Sam's card layout. + +Nora tags the milestone: + +``` +git tag -a v0.5-alpha -m "Alpha: end-to-end sketch-to-options pipeline working" +``` + +She writes the first `CHANGELOG.md` entry and creates a release archive: + +``` +git archive main --prefix='sketchspark-v0.5-alpha/' --format=zip > sketchspark-v0.5-alpha.zip +``` + +The archive goes to the CEO for demo day. The alpha is alive. + +--- + +## Chapter 6 — Public Beta & Community + +The alpha demo goes well. The CEO wants a public beta. The repo goes from private to public on GitHub. + +Going public changes everything. Strangers will see the code, the prompts, the design files. Nora writes `CONTRIBUTING.md` — not for engineers, but for designers: + +- Prompt templates must follow the existing format (system context, then user instruction, then constraints) +- Illustrations must be 2x resolution, brand palette only, PNG export with transparent background +- Icons must sit on a 24x24 grid, 2px stroke, SVG format +- Screen mockups must include both light and dark mode +- All UI contributions must pass WCAG AA contrast requirements + +She expands `README.md` with screenshots of the product, a GIF showing the sketch-to-options flow, a component map, and links to the Figma source files. + +Then Marcus appears. He's a designer in Melbourne — 16 hours ahead of the team. He's been using the beta and thinks the mobile layout generation is weak. He forks the repo, creates `feature/mobile-prompt-template`, and edits `prompts/sketch-to-ui.txt` to add mobile-specific layout constraints. He also adds a new file: `prompts/mobile-layout.txt`. + +He opens a pull request. In the description, he includes before/after screenshots: five generated options from the same sketch, current vs. his improved prompt. The mobile options are noticeably better — less cramped, better touch target sizing. + +Nora reviews the PR the next morning. She's never met Marcus. She leaves feedback: +- The prompt improvement is strong, but the constraint format doesn't match the existing template +- The mobile-layout file needs a header comment explaining when the system uses it vs. the main prompt +- She suggests splitting the touch-target constraint into its own line for readability + +Marcus pushes updates. Nora approves and merges. The whole interaction happens asynchronously over 48 hours, entirely through GitHub comments and annotated screenshots. + +The team sets up GitHub Pages to host product documentation at `sketchspark.github.io` — setup guide, API reference, and contribution guidelines. + +Nora configures the GitHub organization: +- `@core-team`: Nora, Sam, Priya, Kai (write access to all repos) +- `@contributors`: Marcus and other external designers (fork-and-PR workflow) +- `@stakeholders`: CEO, investors (read-only, can comment on PRs) + +The product is no longer just theirs. + +--- + +## Chapter 7 — Production Hardening + +The beta has users. Bugs arrive. Complexity compounds. + +**Sam's stash.** Sam is midway through redesigning the results comparison screen — he's added a new "overlay diff" mode that lets users superimpose two generated options. Half the screens are done, half are placeholders. Then a bug report: the onboarding flow crashes on tablets. The layout breaks at 768px. + +Sam can't commit half-finished work to his branch (the placeholders would confuse reviewers). He stashes: + +``` +git stash push -m "WIP: overlay diff mode for results comparison" +``` + +He switches to `main`, creates `fix/onboarding-tablet-layout`, fixes the responsive breakpoint in the onboarding screens, commits, opens a PR, gets it reviewed, and merges. Then he returns: + +``` +git checkout feature/overlay-diff +git stash pop +``` + +His work-in-progress is exactly where he left it. + +**Priya's blame.** A stakeholder notices that the onboarding illustrations look "off" — the blue tones don't match the brand. Priya uses blame to trace the change: + +``` +git blame illustrations/onboarding/step-2-generate.png +``` + +The file is binary, so blame shows commit metadata but not visual content. She checks the log: + +``` +git log --oneline -- illustrations/onboarding/step-2-generate.png +``` + +Three commits ago, she exported from a file with the wrong color profile. She fixes the source, re-exports, and commits: `Fix color profile on onboarding illustrations (sRGB, not Display P3)`. + +**Nora's interactive staging.** Nora has been updating `product-brief.md` with two unrelated changes: a scope expansion (adding tablet support) and updated user interview findings from round 2. She wants to commit them separately — the scope change needs its own PR and approval, but the research update can merge immediately. + +``` +git add -p product-brief.md +``` + +She stages only the hunks related to interview findings, commits those, then stages and commits the scope expansion separately. Two clean commits instead of one muddled one. + +**Sam's accidental commit to main.** Sam forgets to create a branch. He commits a screen redesign directly to `main`. Branch protection catches it on push — he can't push to `main` without a PR. But the commit exists locally. He fixes it: + +``` +git reset --soft HEAD~1 +git checkout -b feature/screen-redesign +git commit -m "Redesign generation progress screen with loading animation" +``` + +The commit moves to the correct branch. `main` is clean. + +**Priya's messy history.** Priya's icon branch has five commits: + +``` +Add home icon +Fix home icon — wrong stroke width +Update home icon — adjust padding +Add settings icon +Fix settings icon — align to grid +``` + +Before opening her PR, she cleans up with interactive rebase: + +``` +git rebase -i HEAD~5 +``` + +She squashes the home icon commits into one ("Add home navigation icon") and the settings icon commits into one ("Add settings navigation icon"). The PR shows two clean additions instead of five noisy iterations. + +**Kai's submodule.** The AI pipeline has grown complex enough to be its own repository: `sketchspark-ml`. Kai adds it as a submodule of the main product repo: + +``` +git submodule add git@github.com:sketchspark/sketchspark-ml.git pipeline/ +``` + +When the model improves — better option variety, faster generation — Kai updates the submodule pointer in the main repo. The team pulls and gets the latest pipeline version without managing ML code directly. + +--- + +## Chapter 8 — Process & Automation + +The team has grown beyond informal coordination. They need guardrails. + +**Git attributes for binary files.** Nora creates `.gitattributes` to tell Git which files are binary and which can be meaningfully diffed: + +``` +# Binary — don't attempt to diff or merge +*.png binary +*.psd binary +*.fig binary +*.sketch binary + +# Text-based design files — diff normally +*.svg diff +*.md diff +*.json diff +*.yaml diff +*.txt diff + +# Large source files — version but exclude from archives +*.psd export-ignore +*.sketch export-ignore +research/raw-interviews/ export-ignore +``` + +This means `git diff` produces useful output for SVGs, tokens, prompts, and documentation — but doesn't try to diff PNGs or Figma files (which would just show binary garbage). + +**Commit message template.** Nora creates `.gitmessage`: + +``` +[Phase: Component] Short description + +# Phases: Research, Concept, Design, Pipeline, Docs, Fix, Release +# Examples: +# [Design: Results Screen] Add overlay diff comparison mode +# [Research: Persona] Update early-adopter goals after round 2 interviews +# [Pipeline: Prompts] Improve mobile layout generation constraints +# [Fix: Onboarding] Correct tablet breakpoint for step 2 illustration +``` + +She configures it: + +``` +git config commit.template .gitmessage +``` + +Every commit now starts from this template. The `[Phase: Component]` prefix makes `git log --oneline` scannable and `git log --grep="[Design:"` filters to design-only changes. + +**Pre-commit hook.** Nora adds a hook that runs before every commit: + +1. Validates `model-params.yaml` is syntactically correct YAML +2. Checks that prompt templates in `prompts/` don't exceed 4096 tokens (the model's context limit) +3. Warns (but doesn't block) if any PNG file exceeds 5MB + +The hook is a shell script — Nora found a template online and adapted it. She couldn't write it from scratch (she's not a programmer), but she can read it and modify the file size threshold. + +**Commit-msg hook.** A second hook validates that commit messages match the `[Phase: Component]` pattern. If Sam writes "fix stuff", the commit is rejected with a message explaining the expected format. + +**Image metadata diffing.** Nora configures Git to use `exiftool` for PNG diffs. Now `git diff` on an illustration shows metadata changes: dimensions, color profile, export date, DPI. It's not a visual diff, but it catches the color profile mistake that cost Priya time in Chapter 7. + +The team's process is now encoded in the repository itself. New contributors (like Marcus) inherit the rules automatically when they clone. + +--- + +## Chapter 9 — Legacy Migration + +SketchSpark acquires a smaller competitor, **QuickMock**. QuickMock has three years of design assets — mockups, illustrations, user research, and brand materials — stored in a Subversion (SVN) repository on a company server. + +Nora leads the migration. + +**Assessment.** She checks the SVN repo: 2,400 files, 1.2GB total. Most of the size comes from PSD source files (some over 100MB) and high-resolution marketing renders. The text files (research notes, documentation) are small and numerous. + +**Planning.** She decides: +- Import full history for text files (research, documentation, changelogs) — the evolution matters +- Import only the latest version of large binary files (PSDs, high-res PNGs) — old versions of 100MB PSDs aren't useful enough to justify the repo bloat +- Configure Git LFS for files over 10MB going forward +- Map QuickMock's flat folder structure to SketchSpark's organized hierarchy + +**Execution.** She uses `git svn clone` to pull the history: + +``` +git svn clone https://svn.quickmock.internal/trunk quickmock-import --authors-file=authors.txt +``` + +The authors file maps SVN usernames to Git identities so QuickMock's team gets proper attribution. + +Post-import cleanup: +- SVN branch names with `@` suffixes get cleaned up +- Large binaries get migrated to Git LFS: `git lfs migrate import --include="*.psd,*.ai" --above=10mb` +- QuickMock's flat `designs/` folder gets reorganized into SketchSpark's `screens/`, `illustrations/`, and `icons/` structure + +The migration takes a day. The combined repo is 800MB with LFS (down from 1.2GB if everything were inline). Three years of QuickMock's design evolution is now searchable alongside SketchSpark's history. + +Priya notes: "I wish we'd set up LFS from the start. My onboarding illustrations have been bloating the repo since Chapter 5." + +--- + +## Chapter 10 — Scale & Recovery + +It's two days before the v1.0 launch. The team is in final polish mode. Sam is updating screenshots in the documentation. Priya is exporting final marketing assets. Nora is writing release notes. Kai is tuning the model's generation speed. + +Then Sam makes a mistake. + +He means to reset his working directory to discard some local experiments. He types: + +``` +git reset --hard HEAD~3 +``` + +On `main`. He just rewound the main branch by three commits — Nora's release notes, Priya's final marketing illustrations, and Kai's generation speed improvement. All gone from `main`. + +Panic. Then Nora says: "Git doesn't delete anything. It just moves pointers." + +She opens the reflog: + +``` +git reflog +``` + +The reflog shows every position `HEAD` has been in. Three entries up, there's the commit before Sam's reset. She creates a recovery branch: + +``` +git branch recovery a1b2c3d +git checkout recovery +git log --oneline -5 +``` + +All three commits are there. She merges recovery into main: + +``` +git merge recovery +``` + +Everything is restored. The launch stays on schedule. + +This moment — the near-disaster and the recovery — becomes the frame for understanding Git internals: + +**Objects.** Every file version, every directory snapshot, every commit is stored as an object with a unique hash. Nora explains: "When you committed those release notes, Git created an object. When Sam reset `main`, Git didn't delete the object — it just moved the `main` label to point at an older one. The release notes object was still there, just unreachable through normal commands." + +**References.** Branches are labels. Tags are labels. HEAD is a label. Moving them — even destructively — doesn't destroy the underlying objects. Sam's `reset --hard` moved the `main` label backward. Nora's `branch recovery` created a new label pointing at the still-existing commit. + +**Reflog.** Git keeps a log of every label movement for at least 30 days. Even if Sam had deleted the branch, the reflog would still know where it pointed. The reflog is the safety net that makes Git's model robust against human error. + +**Packfiles.** Priya asks why `git clone` takes 45 seconds for a repo with thousands of files. Nora explains: Git packs similar objects together using delta compression. When Priya commits a slightly modified illustration, Git doesn't store a second full copy — it stores the difference. But very large binary files (her PSDs) resist delta compression, which is why LFS exists. + +The internals chapter isn't about cryptographic hash functions or the Git object database's implementation. It's about understanding *why your work is never truly lost* — and why that matters when months of research, design, and AI configuration are at stake. + +--- + +## Appendix A — Tooling Choices + +The team never agreed on one tool. That turned out fine. + +**Nora** uses the command line. Her work is text-heavy — product briefs, research notes, user flows. She types `git status`, `git diff`, `git log --oneline --graph` dozens of times a day. The CLI is fastest for her. + +**Sam** uses VS Code. He edits `design-tokens.json` and `user-flows.md` with Git's inline gutter indicators showing what changed since the last commit. The built-in source control panel lets him stage individual hunks without learning `git add -p` syntax. He reviews PRs with the GitHub Pull Requests extension. + +**Priya** uses GitHub Desktop. She stages files by checking boxes. She sees a visual list of changed files — critical when her commits include a dozen illustration exports. Drag-and-drop staging and clear binary file indicators ("This file has changed but can't be displayed") match how she thinks about her work. + +**Kai** uses JetBrains (WebStorm). The integrated terminal, diff viewer, and Git log sit alongside his Python and JavaScript code. He resolves merge conflicts in the three-pane merge tool without leaving his IDE. + +The appendix presents a decision tree: +- "I mainly write text and research documents" → CLI or VS Code +- "I work with lots of image files" → GitHub Desktop +- "I write code alongside design work" → VS Code or JetBrains +- "I want the simplest possible interface" → GitHub Desktop +- "I want maximum control" → CLI + +No choice is wrong. The best Git tool is the one you'll actually use. + +--- + +## Appendix B — Tool Integration + +Kai gives the team a look behind the curtain. + +SketchSpark's own architecture uses Git internally. When a user uploads a sketch and the system generates 5 UI options, each option is created as a lightweight branch in a temporary repository using **libgit2** (C library, called from the Python backend). The user's "compare options" screen is reading from Git branches. The "pick this one" button is a merge. The product's UX is a Git workflow — the user just never sees `git` commands. + +This reframing — "you've been using Git concepts all along without knowing it" — lands differently now that readers understand branches and merges from their own experience. + +Priya is intrigued by a different angle. She wants to automate her export workflow: every time she exports illustrations from her design tool, a script should auto-commit them to Git. She finds **Dulwich**, a Python Git library, and writes a script: + +```python +# Simplified — watches export folder and auto-commits new PNGs +from dulwich.repo import Repo +repo = Repo(".") +repo.stage(["illustrations/onboarding/step-1-upload.png"]) +repo.do_commit(b"Auto-export: updated onboarding illustration step 1") +``` + +It's ten lines of code (Kai helps with the details). Now her Git workflow is: export from design tool → script commits automatically → she opens a PR when the batch is ready. The manual `git add` / `git commit` cycle disappears for her binary file workflow. + +The appendix isn't about learning to write Git libraries. It's about understanding that the tools designers already use — GitHub Desktop, Figma plugins, CI/CD pipelines — are built on these libraries. Knowing they exist demystifies "how does GitHub Desktop work?" and opens the door to simple automation. + +--- + +## Appendix C — Reference + +The command reference is organized by SketchSpark workflow, not alphabetical command taxonomy. + +**Starting a Project** +- `git init` — Create a new repository (Nora in Chapter 2) +- `git clone` — Copy an existing repository (Sam joining in Chapter 3) +- `git config` — Set your name, email, editor, commit template (Chapter 1, Chapter 8) + +**Daily Design Work** +- `git status` — What's changed since my last commit? +- `git add` — Select files to include in the next commit +- `git add -p` — Select specific changes within a file (Nora in Chapter 7) +- `git commit` — Save a checkpoint with a message +- `git diff` — What exactly changed? (works for text files; limited for binary) +- `git stash` — Set aside work-in-progress temporarily (Sam in Chapter 7) + +**Exploring & Branching** +- `git branch` — List, create, or delete branches +- `git checkout` / `git switch` — Move to a different branch +- `git merge` — Combine one branch into another +- `git rebase` — Replay commits onto a different base (Sam in Chapter 3) + +**Collaborating** +- `git remote` — Manage connections to shared repositories +- `git push` — Send your commits to the shared repository +- `git pull` — Download and merge teammates' changes +- `git fetch` — Download without merging (check first, merge later) + +**Reviewing History** +- `git log` — See commit history (with `--oneline --graph` for visual overview) +- `git log -S "keyword"` — Find when a specific term was added or removed +- `git blame` — Find who last changed each line of a file (Priya in Chapter 7) +- `git show` — Display a specific commit's contents + +**Shipping a Release** +- `git tag` — Mark a commit as a release (v0.1-concept, v0.5-alpha, v1.0) +- `git archive` — Create a distributable zip/tar without Git history + +**Fixing Mistakes** +- `git restore` — Discard uncommitted changes to a file +- `git restore --staged` — Unstage a file without losing changes +- `git reset --soft HEAD~1` — Undo the last commit, keep changes staged (Sam in Chapter 7) +- `git revert` — Create a new commit that undoes a previous commit (safe for shared branches) +- `git reflog` — Find lost commits after a destructive operation (Nora in Chapter 10) + +**Maintaining Quality** +- `git clean` — Remove untracked files (caution: irreversible for design exports) +- `git lfs` — Manage large binary files (illustrations, PSDs) without bloating the repo + +Each command links back to the chapter where it appears in the storyline, so readers can revisit the full context. + +--- + +## Recurring Threads + +These themes weave through every chapter, creating continuity beyond the plot: + +**Binary vs. Text.** Introduced in Chapter 1 (Nora's question about Sketch files), demonstrated in Chapter 2 (wireframe PNGs vs. markdown briefs), painful in Chapter 5 (Priya's large illustrations), configured in Chapter 8 (`.gitattributes`), resolved in Chapter 9 (Git LFS). Every chapter reinforces: text files are Git's strength; binary files require extra care. + +**The Five Options.** The product generates 5 options from 1 sketch. Git creates parallel branches from 1 commit. This parallel is explicit in Chapter 3 (Sam's three `option/` branches), implicit in Chapter 5 (four parallel feature branches), and architectural in Appendix B (the product uses Git branches internally). The metaphor deepens as the reader's Git knowledge grows. + +**Design Decisions as Commits.** Every commit in the storyline represents a design decision — not a code change. "Update primary color for accessibility," "Add tablet breakpoint to onboarding," "Improve mobile generation prompt." This reframes Git from a developer tool to a design decision ledger. + +**Progressive Team Growth.** Chapter 1: solo. Chapter 2: solo with structure. Chapter 3: pair. Chapter 5: team of four. Chapter 6: open community. Each growth stage introduces the Git workflow that stage demands — tags when you're solo, branches when you're two, integration manager when you're four, fork-and-PR when you're open source. + +**The Safety Net.** Git's ability to recover from mistakes is introduced gently (undo in Chapter 2), tested (reset in Chapter 7), and fully proven (reflog recovery in Chapter 10). By the final chapter, the reader trusts that Git protects their work — the same trust that motivated Nora to adopt it after her file loss in Chapter 1. The story ends where it began: your work is never truly lost. diff --git a/sketchspark-author/references/voice.md b/sketchspark-author/references/voice.md new file mode 100644 index 000000000..0cf60d6e3 --- /dev/null +++ b/sketchspark-author/references/voice.md @@ -0,0 +1,30 @@ +# Voice and Tone Guide - Pro Git for UX Designers + +This guide defines how we speak to our audience: UX Designers, UI Designers, Product Designers, and researchers who may be new to Git and the Command Line. + +## Audience +- **Fluency:** Expert in design concepts (hierarchy, tokens, flows, research), novice in development infrastructure (Git, CLI, build pipelines). +- **Motivation:** Solving collaboration pain, preventing file loss, managing large design systems, contributing to open-source or engineering workflows. +- **Tools:** Figma, Sketch, Adobe Creative Cloud, GitHub Desktop, VS Code. + +## Tone +- **Professional but Approachable:** Speak like a senior peer, not a professor. +- **Empathetic:** Acknowledge the steep learning curve of the CLI. Avoid "simply," "obviously," or "just." +- **Visual:** Use visual metaphors. A branch is a parallel design exploration; a commit is a design checkpoint. +- **Practical:** Focus on "What does this mean for my design workflow?" rather than "How does this work in the Git internals?" (save internals for Chapter 10). + +## Writing Guidelines +- **Context before Syntax:** Explain *why* you are running a command and what you hope to achieve *before* showing the code block. +- **Narrative-Driven:** Use Nora, Sam, Priya, and Kai's story to ground every technical lesson in a realistic scenario. +- **Terminology:** + - **Commit:** A "checkpoint" or "snapshot" of the project's state. + - **Branch:** A "parallel exploration" or "version of the truth." + - **Merge:** "Integrating" or "reconciling" changes. + - **Staging Area:** The "selection" for the next checkpoint. +- **CLI Commands:** Always provide a brief breakdown of what each flag or argument does. + +## Character Voices +- **Nora (UX Lead):** Structured, methodical, process-oriented. Speaks in terms of research integrity and project health. +- **Sam (UI Designer):** Fast, experimental, sometimes messy. Asks the "what if I mess up?" questions. +- **Priya (Illustrator):** Focused on large assets, visual quality, and high-fidelity source files. Concerned about repo bloat and binary handling. +- **Kai (Engineer):** Bridges the gap. Explains the "why" behind the infrastructure in a way that relates to design tokens and model prompts. diff --git a/sketchspark/.gitattributes b/sketchspark/.gitattributes new file mode 100644 index 000000000..e69de29bb diff --git a/sketchspark/.gitignore b/sketchspark/.gitignore new file mode 100644 index 000000000..75ee30cdf --- /dev/null +++ b/sketchspark/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +__MACOSX/ +*.sketch~ +*.figma_cache +Thumbs.db diff --git a/sketchspark/CHANGELOG.md b/sketchspark/CHANGELOG.md new file mode 100644 index 000000000..e69de29bb diff --git a/sketchspark/CONTRIBUTING.md b/sketchspark/CONTRIBUTING.md new file mode 100644 index 000000000..e69de29bb diff --git a/sketchspark/concept/information-architecture.md b/sketchspark/concept/information-architecture.md new file mode 100644 index 000000000..e69de29bb diff --git a/sketchspark/concept/user-flows.md b/sketchspark/concept/user-flows.md new file mode 100644 index 000000000..e69de29bb diff --git a/sketchspark/design-tokens.json b/sketchspark/design-tokens.json new file mode 100644 index 000000000..ec0e45182 --- /dev/null +++ b/sketchspark/design-tokens.json @@ -0,0 +1,14 @@ +# Design Tokens + +{ + "colors": { + "primary": "#2563EB", + "secondary": "#7C3AED", + "surface": "#FFFFFF", + "on-surface": "#1E293B" + }, + "spacing": { + "md": "16px", + "lg": "24px" + } +} diff --git a/sketchspark/pipeline/model-params.yaml b/sketchspark/pipeline/model-params.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/sketchspark/product-brief.md b/sketchspark/product-brief.md new file mode 100644 index 000000000..c97d4b307 --- /dev/null +++ b/sketchspark/product-brief.md @@ -0,0 +1,15 @@ +# SketchSpark Product Brief + +## Vision +SketchSpark is an AI-powered rapid prototyping application that turns rough sketches into polished UI designs. + +## Core Features +- Upload or draw a rough sketch. +- Generate up to 5 parallel UI interpretations. +- Compare options side-by-side. +- Export to Figma, SVG, or React. + +## Audience +- Freelance UI/UX Designers +- Design Teams in fast-paced startups +- Product Managers doing rapid discovery diff --git a/sketchspark/research/competitive-analysis.md b/sketchspark/research/competitive-analysis.md new file mode 100644 index 000000000..e69de29bb