DEV Community

Cover image for Git Switch
Kumar Nitesh
Kumar Nitesh

Posted on

Git Switch

Another unknown command, but with a disclaimer

THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.

How do I used to switch branch

// switch to existing branch
$ git checkout <existing_branch>
// create and switch to new branch
$ git checkout -b <new_branch>

How I have started switching branch now

// switch to existing branch
$ git switch <existing_branch>
// create and switch to new branch
$ git switch -c <new_branch>

All git switch options

git switch [<options>] [--no-guess] <branch>
git switch [<options>] --detach [<start-point>]
git switch [<options>] (-c|-C) <new-branch> [<start-point>]
git switch [<options>] --orphan <new-branch>

Enter fullscreen mode Exit fullscreen mode

Read More

Kumar Nitesh

Top comments (0)