DEV Community

Cover image for How to create a new branch in Git?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to create a new branch in Git?

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 😃.


Top comments (0)