git switch -c: create a branch and switch in one command

calendar_today timer Reading time ~1 minute

Did you know you can create a branch in git and change to it all with a single command? Well, there are actually two commands that can help you do this, but today we are going to talk about git switch. 🤔

git switch is the command for changing branches, so you switch from one branch to another. But there is a little flag you can use to create the branch and then make the switch: -c. C stands for create.

So when you run git switch -c and then give your branch name, git creates your branch and switches you over to that new branch.

That makes creating branches a lot easier.

Want the longer version? I covered this in more depth here: Creating a new branch and switching to it with only one command

Follow for more tricks like this!

animated jess' signature

Related Articles