Skip to content

Commit 23da0ac

Browse files
authored
Merge pull request #1523 from HonkingGoose/add-note-about-git-switch
2 parents f6073f2 + e8fda62 commit 23da0ac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

book/03-git-branching/sections/nutshell.asc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,12 @@ Let's see why you should do so.
198198
====
199199
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 <newbranchname>`.
200200
====
201+
202+
[NOTE]
203+
====
204+
From Git version 2.23 onwards you can use `git switch` instead of `git checkout` to:
205+
206+
- Switch to an existing branch: `git switch testing-branch`.
207+
- 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`.
208+
- Return to your previously checked out branch: `git switch -`.
209+
====

0 commit comments

Comments
 (0)