From e8fda6245158f50859871dbf92ad227551a4e779 Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Sat, 12 Sep 2020 11:27:03 +0200 Subject: [PATCH] Create note for `git switch` Git 2.23 comes with the experimental command `git switch`. This commit adds a note with the most common operations that readers will want to use `git switch` for. --- book/03-git-branching/sections/nutshell.asc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/book/03-git-branching/sections/nutshell.asc b/book/03-git-branching/sections/nutshell.asc index 43461b17f..3818d939a 100644 --- a/book/03-git-branching/sections/nutshell.asc +++ b/book/03-git-branching/sections/nutshell.asc @@ -198,3 +198,12 @@ Let's see why you should do so. ==== 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 `. ==== + +[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 -`. +====