Skip to content

Rewrite recommend git switch instead of git checkout #1524

Open

Description

@HonkingGoose

Which version of the book is affected?

This affects our mainline branch, when macOS and Debian stable include newer versions of Git that have the git switch command.

Describe the bug:

When stable platforms use newer versions of Git, we should not be using git checkout as the recommended way to do things, and instead promote git switch usage.

Steps to reproduce:

Just look through the book and note that we use git checkout instead of git switch.

Expected behavior:

What the rewrite should do:

  • Get rid of the [NOTE] that pull Create note for git switch #1523 introduced.
  • Rewrite book to use git switch instead of git checkout where possible.
  • Add [NOTE] explaining that git checkout is the "old way" of doing things.

Screenshots:

Additional context:

From @ben at #1515 (comment):

We can rewrite to recommend switch first and checkout as a note when MacOS and (apparently) Debian stable have newer versions.

From @Paebbels:

When Git 2.27+ is bundled with most common distributions (e.g. Debian stable), the usage of git checkout can be degraded to a foot note or so.

I copied/pasted @ben's words, so that we can keep track of this issue here, instead of on a issue (#1515) that will be closed when my pull is merged.

Activity

  1. AlgaedAhmed commented on Sep 22, 2020

    @AlgaedAhmed

  2. changed the title [-]Rewrite recommend `git switch` instead of `git checkout`, when MacOS and Debian stable update their Git[/-] [+]Rewrite recommend `git switch` instead of `git checkout`, when macOS and Debian stable update their Git[/+] on Dec 4, 2020
  3. HonkingGoose commented on Feb 14, 2023

    @HonkingGoose
    ContributorAuthor

    Looks like we're good to go for this issue now! See the discussion in this issue for more details about the current versions of Git:

  4. changed the title [-]Rewrite recommend `git switch` instead of `git checkout`, when macOS and Debian stable update their Git[/-] [+]Rewrite recommend `git switch` instead of `git checkout`[/+] on Feb 14, 2023
  5. das-g commented on Oct 6, 2026

    @das-g
    • Rewrite book to use git switch instead of git checkout where possible.

    Where it's not possible, git checkout is probably being used to retrieve file contents of some revision (commit, staging area or stash) into the working copy without moving HEAD. If so, that can be done with git restore and thus could (and IMO should) probably be replaced by that.

  6. added a commit that references this issue on Oct 11, 2026
    2246f78
  7. das-g commented on Oct 11, 2026

    @das-g

    What do you think of my draft at #2095?

  8. added 2 commits that reference this issue on Oct 11, 2026
    62e8dfa
    dafbb22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions