What is the command to create a new branch in Git?

What is the command to create a new branch in Git?

a) git branch new-branch
b) git new-branch
c) git checkout branch
d) git switch branch

Answer:

a) git branch new-branch

Explanation:

The git branch new-branch command creates a new branch named “new-branch” in the current repository. This branch is based on the current commit and allows you to work on changes independently from other branches.

Once the new branch is created, you can switch to it using git checkout new-branch or git switch new-branch to start working on it. This separation allows multiple developers to work on different features without affecting each other’s work.

Branches are fundamental to collaborative workflows, enabling teams to develop features in parallel and later merge them into the main project.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top