ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 218 - XK0-005 discussion

Report
Export

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?

A.
git branch ---m staging
Answers
A.
git branch ---m staging
B.
git commit ---m staging
Answers
B.
git commit ---m staging
C.
git status ---b staging
Answers
C.
git status ---b staging
D.
git checkout ---b staging
Answers
D.
git checkout ---b staging
Suggested answer: D

Explanation:

The correct answer is D. git checkout -b staging

This command will create a new branch named staging and switch to it. The git checkout command is used to switch between branches or restore files from a specific branch. The -b option is used to create a new branch if it does not exist. For example, git checkout -b staging will create and switch to the staging branch.

The other options are incorrect because:

A) git branch -m staging

This command will rename the current branch to staging, not switch to it. The git branch command is used to list, create, or delete branches. The -m option is used to rename a branch. For example, git branch -m staging will rename the current branch to staging.

B) git commit -m staging

This command will commit the changes in the working tree to the current branch with a message of staging, not switch to it. The git commit command is used to record changes to the repository. The -m option is used to specify a commit message. For example, git commit -m staging will commit the changes with a message of staging.

C) git status -b staging

This command will show the status of the working tree and the current branch, not switch to it. The git status command is used to show the state of the working tree and the staged changes. The -b option is used to show the name of the current branch. However, this option does not take an argument, so specifying staging after it will cause an error.

Git - git-checkout Documentation

Git Tutorial: Create a New Branch With Git Checkout

Git Branching - Basic Branching and Merging

asked 02/10/2024
shikeba barakzei
34 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first