nerdexam
CompTIA

XK0-005 · Question #699

A DevOps engineer is working on a local copy of a Git repository. The engineer would like to switch from the main branch to the staging branch but notices the staging branch does not exist. Which of…

The correct answer is D. git checkout -b staging. The git checkout -b staging command creates a new branch called staging and switches to it. This is useful when you want to create a new branch locally and begin working on it. The -b flag is used to create the branch if it doesn't exist.

Scripting, Containers, and Automation

Question

A DevOps engineer is working on a local copy of a Git repository. The engineer would like to switch from the main branch to the staging branch but notices the staging branch does not exist. Which of the following Git commands should the engineer use to perform this task?

Options

  • Agit branch -m staging
  • Bgit commit -m staging
  • Cgit status -b staging
  • Dgit checkout -b staging

How the community answered

(38 responses)
  • A
    8% (3)
  • B
    3% (1)
  • C
    3% (1)
  • D
    87% (33)

Explanation

The git checkout -b staging command creates a new branch called staging and switches to it. This is useful when you want to create a new branch locally and begin working on it. The -b flag is used to create the branch if it doesn't exist.

Topics

#Git#Branching#Version Control#CLI Commands

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice