From: Junio C Hamano <gitster@pobox.com>
To: "Julia Evans via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
"D. Ben Knoble" <ben.knoble@gmail.com>,
Julia Evans <julia@jvns.ca>
Subject: Re: [PATCH] doc: add tutorial on branches for beginners
Date: Tue, 24 Nov 2026 09:16:22 -0800 [thread overview]
Message-ID: <xmqqa4myup3t.fsf@gitster.g> (raw)
In-Reply-To: <pull.2307.git.1794259990263.gitgitgadget@gmail.com> (Julia Evans via GitGitGadget's message of "Mon, 09 Nov 2026 21:33:10 +0000")
"Julia Evans via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Julia Evans <julia@jvns.ca>
> ...
> +Next, edit README.md and make another commit, like this:
> +
> +----
> +git commit -am "Update README.md"
> +----
> +
> +`git commit -am` commits the current version of all files that Git is
> +tracking.
> +
> +Now we're set up and we can start creating branches.
> +
> +Step 2: Find your current branch
> +--------------------------------
> +
> +In Git, you normally have a "current branch". You can see your current
> +branch by running `git status`. It's usually on the first line, like this:
> +
> +----
> +$ git status
> +
> +On branch main
> +----
After reading through the steps, the abrupt appearance of the "$" prompt
feels a bit disorienting. You have a good reason to use a prompt here,
to make it possible to tell what you type and what the commands tell you
apart. Wouldn't it be better to use the prompt consistently, e.g.,
making the last example of the previous step
----
$ git commit -a -m "Update README.md"
----
instead?
Side note. Yesterday I learned while reviewing an unrelated
patch that we encourage users not to squish short options
together into a single word, so I split your "-am <msg>" in the
above rewrite of the example.
There are a handful of other places where you add the "$" prompt in a
block that has both input and output, and many blocks that lack the "$"
prompt. The mixture looks rather messy.
> +Example: Emilia the PhD student
> +-------------------------------
> +
> +Emilia is writing her PhD thesis. She follows the steps from
> +linkgit:gittutorial[7] to set up a Git repository on the Internet so
> +that she can back up her work.
> +
> +To back up her work after making a commit, she runs:
> +
> +----
> +git push origin main
> +----
> +
> +Sometimes, she creates a branch to make an experimental change she's not
> +sure that she's going to keep, like `rewrite-chapter-5`.
> +
> +She does this by running:
> +
> +----
> +git switch -c rewrite-chapter-5
> +----
Would it help to explicitly mention that after running 'switch -c'
to create the branch, Emilia actually does some work on it before
the "If she decides to keep/If she decides to discard" paragraphs?
> +
> +If she decides that the experimental change should be merged, she merges
> +it into `main` like this:
> +
> +----
> +git switch main
> +git merge rewrite-chapter-5
> +----
> +
> +Or if she decides the rewrite of chapter 5 was a bad idea, she can
> +delete the branch:
> +
> +----
> +git branch -D rewrite-chapter-5
> +----
This is slightly misleading after saying "Or if she decides", which
implies that the previous one did not happen. If she did not switch
to 'main' and merge, she would still be on the rewrite-chapter-5
branch, and the "branch -D", even with a capital "-D", would fail.
Perhaps make the example switch back to 'main' before discarding the
branch?
> +Example: Daniela and Carmen with the cat shelter website
> +--------------------------------------------------------
> +
> +Daniela and Carmen create a Git repository for their cat shelter website.
A very minor thing, but wouldn't breaking the alphabetical order of
appearance of the characters be a bit jarring to readers? Does this
example need to be about Daniela and Carmen, not Carmen and Daniela?
> +They both clone it onto their computer like this:
> +
> +----
> +git clone git@example.com:cat-shelter/kitties.git
> +----
> +
> +They decide to work together by just pushing all of their commits to the
> +`main` branch, without using any other branches.
> +
> +When Daniela wants to do work, she first runs `git pull` on the main
> +branch, like this:
> +
> +----
> +git pull
> +----
> +
> +She also checks in with Carmen to make sure they won't be working on
> +the same files. Then she works on her changes. Then, before pushing her
> +changes, she runs this command to merge any changes Carmen has made.
Wouldn't it be helpful to be more explicit that before running this
command (git pull), she commits all her work? We assume that "pull"
somehow finishes cleanly, so ...
> +----
> +git pull --no-rebase
> +----
> +
> +We don't have space for a full introduction to linkgit:git-pull[1]
> +here, but `git pull` fetches Carmen's changes and merges them into the
> +current branch. The `--no-rebase` flag tells Git to use `git merge` to
> +do the merge.
> +
> +Then she pushes her changes with:
> +
> +----
> +git push
> +----
... there is no extra need for "git commit" before the "git push" that
comes after the "git pull --no-rebase".
Thanks.
next prev parent reply other threads:[~2026-11-24 17:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 21:33 [PATCH] doc: add tutorial on branches for beginners Julia Evans via GitGitGadget
2026-11-09 21:56 ` Junio C Hamano
2026-11-09 22:01 ` Julia Evans
2026-11-09 22:11 ` Junio C Hamano
2026-11-10 14:31 ` Julia Evans
2026-11-18 12:43 ` Julia Evans
2026-11-23 18:05 ` D. Ben Knoble
2026-11-23 18:05 ` D. Ben Knoble
2026-11-24 15:56 ` Julia Evans
2026-11-24 19:04 ` Ben Knoble
2026-11-24 17:16 ` Junio C Hamano [this message]
2026-11-24 21:13 ` [PATCH v2] " Julia Evans via GitGitGadget
2026-11-30 15:09 ` D. Ben Knoble
2026-11-30 16:10 ` Julia Evans
2026-11-30 17:00 ` D. Ben Knoble
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqa4myup3t.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=julia@jvns.ca \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox