Creating Branches
Creating a Branch
Command 1: Create only
git branch <branch-name>
- Creates a new branch.
- Does not switch to it.
- You’re still on the same branch as before.
Command 2: Create + switch
git checkout -b <branch-name>
- Shortcut: creates the branch and switches to it.
- Older syntax.
Command 3: Modern way
git switch -c <branch-name>
- Recommended modern syntax.
- Does the same thing as checkout -b.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.