Microsoft

GH-900 practice question 9

GitHub Foundations · free question 9 of 20

Question

What command should you type to create and switch over to a new branch?
  • A. git checkout -n newBranchName
  • B. git checkout -b newBranchName Correct
  • C. git checkout newBranchName
  • D. git branch newBranchName

Explanation

git checkout -b newBranchName creates the branch and checks it out in a single step (git switch -c does the same in newer Git versions). git branch newBranchName only creates the branch and leaves you on the current one. git checkout newBranchName switches to a branch that already exists, and -n is not a branch-creation option of git checkout.

Practice the whole free set

Answer all 20 free GH-900 questions with instant feedback, or unlock all 126 questions with Learn and Exam modes.