From f667660ffa0d239317f6b87fd1b44e948cea9e7b Mon Sep 17 00:00:00 2001 From: Asocia Date: Wed, 30 Jun 2021 13:24:27 +0300 Subject: [PATCH] Add a note about switching branches --- git/notes-from-pro-git-book.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git/notes-from-pro-git-book.md b/git/notes-from-pro-git-book.md index 0d91df4..149c4aa 100644 --- a/git/notes-from-pro-git-book.md +++ b/git/notes-from-pro-git-book.md @@ -41,3 +41,9 @@ $ git fetch pb ``` Paul’s master branch is now accessible locally as pb/master — you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it. +- Using git switch to create and checkout branches + +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 -`.