On Tue, Nov 24, 2026 at 4:13 PM Julia Evans via GitGitGadget <gitg…@gmail.com> wrote:
> > From: Julia Evans <jul…@jvns.ca> > > Because Git's branches are so flexible and the meaning of a branch is > only what people assign to it, it's important to talk about some of the > social context about branches. Do this in two ways: > > 1. Introduce some imaginary characters who are learning branches for the > first time and examples of workflows they might use. Test readers > said this was helpful because it helped them see different ways > they might use branches. > 2. Explain the importance of a "main" or "master" branch in many > projects, and give a few examples of how projects might use it. > > On `git log`: > > - Use the output of `git log --graph` to visualize branches instead of > a more abstract ASCII diagram, since it serves a double purpose of > teaching people how to read `git log`'s output. > But also mention that folks may prefer to use a GUI to visualize > branches. > - Include two sections to explain the output of `git log`, since several > test readers found it very hard to understand. In that explanation, > only explain `HEAD` fairly briefly and instead keep the focus on the > idea of a "current branch", since that's the term Git's UI normally > uses. > > On the conceptual introduction at the beginning: > > - One of the biggest issues with explaining branches is that there are 3 > ways in Git to think of branches and it's not straightforward to > explain how to reconcile them: > 1. just the commits that "branch off" > 2. the latest commit on the branch > 3. the full history since the beginning of time > Handle this by starting with the "tree" metaphor where branches > "branch off" a central trunk (way 1), since this makes sense with how > people actually want to use branches. Point out some issues with the > tree metaphor and talk about how it relates to the way Git represents > branches (way 2). > - Avoid using computer science jargon, because it's a major barrier to > folks without a CS background. It's not useful or realistic to teach > most beginners the term "directed acyclic graph" just so they can > learn branches. Mention the term "directed acyclic graph" briefly in a > note for folks who are already familiar with that term and link folks > to the data model if they'd like more information. > - Include some basic facts about commits. Folks seemed to find this > helpful, one person said they didn't realize it would be so hard to > change their email address later. > > To keep it readable: > - Don't assume that the reader has read `gittutorial`, and instead > refer back to it explicitly if it's relevant. > - Always include the output for every command. Test readers said > this was helpful. > > Other choices about material that is/isn't included: > > - `git-prompt.sh` (yes): Mention how important it is to be aware > what branch you're on, and suggest using `git-prompt.sh`. Link to > git-prompt.sh on GitHub since several test readers couldn't find it on > their machine. The test readers liked this. > - fast-forward merges (yes): Explain the difference between a fast-forward > merge and a merge commit by giving examples of what each one looks > like. > - upstreams/rebase (no): Don't explain what an upstream is or introduce > rebase, since we're already introducing a lot of concepts. Instead > include a "Where to learn more" section with some pointers to where to > continue learning. > - GUIs (yes): Some readers wanted a suggestion for what GUI to use. It's > very hard to suggest an appropriate GUI because there are so many and > so many of them are not open source, but give a couple of suggestions > of open source tools that seem to be popular with the community. Also > mention that many non-open-source IDEs have built-in Git integrations > for folks who are already using those tools who might not be aware, > since they're a popular way to use Git. > > Co-Authored-By: Marie Claire LeBlanc Flanagan <hel…@marieflanagan.com> > Signed-off-by: Marie Claire LeBlanc Flanagan <hel…@marieflanagan.com> > Signed-off-by: Julia Evans <jul…@jvns.ca> > --- > doc: add tutorial on branches for beginners > > This was reviewed by 17 test readers who overall said it helped them > understand branches. We addressed the feedback from the test readers to > improve it before submitting it here. > > I think it would be good to add a little table of contents to > gittutorial.adoc to match this one's TOC as well. I'm not sure what the > best way to do that is since my understanding is that rebasing on the > latest master causes problems. > > Changes in v2: > > * Use a $ for the commands for consistency (thanks to Junio) > * Add more details in the example workflows to make sure they make > sense logically (thanks to Junio) > * Make sure the characters are alphabetized in the section order and in > sentences. Rename Emilia -> Anita, Abdul -> Bruno, Betsy -> Carmen, > Carmen and Daniela -> Daniela and Emilia. Keep the genders the same > so we don't have to change all the pronouns. (thanks to Junio) > * Deal with the poorly structured sections that Ben pointed at the end > as follows: > * Add a summary at the beginning to explain the overall structure > * Move "3 ways to think about a branch" to the middle, right after > creating the branch we're using as an example > * Move the merge conflicts section to a note at the end of Step 13 > * Rename some of the headings to more clearly explain the structure > (around "the step by step tutorial" and "Examples of using branches > to collaborate") > * Delete the "We normally start from main because if you create a > branch called two..." explanation and instead just say that we want > to keep branches independent (thanks to Ben) > * One test reader said that in "3 ways to think about a branch", it was > confusing to them than #1 and #3 were the same (just one commit). Add > an extra commit to the add-fruits branch so that the branch has 2 > commits, to make it more clear what a branch with multiple commits on > it looks like. > > Note: I used this script > https://gist.github.com/jvns/bcd36fdd42952b9ec9a67ec139dba13e to create > the example repository used in this document and to copy and paste the > example output from. Not sure if we should store the contents of that > script somewhere: it's very annoying to update the examples without it. > I also realized there's an issue with that script where, because it > hardcodes GIT_COMMITTER_DATE, all the commits happen at the same time, > which makes the order of git log a bit weird. I manually adjusted Step > 12 to account for that. > > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2307%2Fjvns%2Ftutorial-branches-v2 > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2307/jvns/tutorial-branches-v2 > Pull-Request: https://github.com/gitgitgadget/git/pull/2307 > > Range-diff vs v1:
From the range-diff, I can see all my feedback was addressed (and I like the new table of contents), along with some of what Junio mentioned (I didn't look for "all", I'm not making a claim anything was missed) and some typo-fixes. Very nice!
> +Step 8: Create another branch > +----------------------------- > + > +Now create a second branch called `add-animals`. We're creating two > +branches to show what the process of working on multiple changes at the > +same time looks like. > + > +You'll usually want to start all new branches from the `main` branch > +to keep your branches independent from each other. Right now > +we're on the `add-fruits` branch, so we need to switch back to the > +`main` branch: > + > +----- > +$ git switch main > +----- > + > +Then create a branch called `add-animals`. > + > +----- > +$ git switch -c add-animals > +-----
I assume we are choosing not to teach "git switch -c add-animals main" for some reason here? One reason I can imagine is that, depending on config like branch.autoSetupMerge and the shape of the 2nd argument (main with config=inherit, origin/main with default config, etc.), we end up configuring an upstream, and you said this tutorial intentionally omits that. So while someone following the tutorial who has not configured branch.autoSetupMerge away from the default would not have any surprising upstream behavior from "git switch -c add-animals main" we cannot control what will or won't happen, which might be confusing. Is that what you were thinking, or something else? (One reason I point it out is that I'm a personal fan of the ways Git helps me type *less*, and I think the "multiple commands to achieve one logical thing" contributes to the scary/complex reputation---OTOH, avoiding upstream stuff here seems like the right way to go.)
-- D. Ben Knoble