200-901 · Question #125
How is a branch called "my-bug-fix" started to develop a fix needed in a product?
The correct answer is B. git checkout -b my-bug-fix. The correct Git command to simultaneously create a new branch and switch to it is git checkout -b my-bug-fix. The -b flag tells Git to create the branch if it does not already exist, then check it out. Choice A is wrong because git branch -b is not valid syntax (git branch does…
Question
How is a branch called "my-bug-fix" started to develop a fix needed in a product?
Options
- Agit branch -b my-bug-fix
- Bgit checkout -b my-bug-fix
- Cgit checkout my-bug-fix
- Dgit branch my-bug-fix
How the community answered
(36 responses)- A3% (1)
- B94% (34)
- D3% (1)
Explanation
The correct Git command to simultaneously create a new branch and switch to it is git checkout -b my-bug-fix. The -b flag tells Git to create the branch if it does not already exist, then check it out. Choice A is wrong because git branch -b is not valid syntax (git branch does not use a -b flag). Choice C (git checkout my-bug-fix) would only switch to an existing branch; it fails if the branch does not yet exist. Choice D (git branch my-bug-fix) creates the branch but does NOT switch to it - you would still be on your current branch after running it.
Topics
Community Discussion
No community discussion yet for this question.