Sobes.tech
Senior

How to create a new branch using a command in Git?

sobes.tech AI

Answer from AI

To create a new branch in Git, use the command:

git branch <branch-name>

For example:

git branch feature/new-feature

However, it is more common to create and switch to a new branch immediately with the command:

git checkout -b <branch-name>

Or in newer versions of Git:

git switch -c <branch-name>

This will create a new branch and switch to it, which is convenient for further work.