DEV Community

loading...
Cover image for How to create a new branch in Git?

How to create a new branch in Git?

MELVIN GEORGE
Hi, I'm Melvin George, A web developer, and a blogger.
Originally published at melvingeorge.me ・1 min read

Originally posted here!

To create a new branch in Git, you can use the git checkout command followed by the flag -b and then type the name of the branch you need to make.

For example, to make a branch called my-new-branch you can use the git checkout command like this,

# Creates a new git branch
git checkout -b my-new-branch
Enter fullscreen mode Exit fullscreen mode

This will create a branch called my-new-branch and will automatically check you into it (aka, set the current working branch to my-new-branch).

That's all 😃!

Feel free to share if you found this useful 😃.


Discussion (0)