You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rewrite recommend git switch instead of git checkout #1524
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.
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
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
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.
Activity
AlgaedAhmed commentedon Sep 22, 2020
[-]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[/+]HonkingGoose commentedon Feb 14, 2023
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:
git restoreinstead ofgit reset#1529[-]Rewrite recommend `git switch` instead of `git checkout`, when macOS and Debian stable update their Git[/-][+]Rewrite recommend `git switch` instead of `git checkout`[/+]das-g commentedon Oct 6, 2026
Where it's not possible,
git checkoutis probably being used to retrieve file contents of some revision (commit, staging area or stash) into the working copy without movingHEAD. If so, that can be done withgit restoreand thus could (and IMO should) probably be replaced by that.merge together changes favoring `switch` and `restore` over `checkout`
das-g commentedon Oct 11, 2026
What do you think of my draft at #2095?
merge together changes favoring `switch` and `restore` over `checkout`
merge together changes favoring `switch` and `restore` over `checkout`