350-901 · Question #77
A developer plans to create a new bugfix branch to fix a bug that was found on the release branch. Which command completes the task?
The correct answer is C. git checkout -b BUG FIX RELEASE. To create a new branch from an existing one in Git, the git checkout -b <new-branch-name> <starting-point-branch> command is used.
Question
Options
- Agit checkout -b RELEASE BUGFIX
- Bgit checkout -t BUGFIX RELEASE
- Cgit checkout -b BUG FIX RELEASE
- Dgit checkout -t RELEASE BUGFIX
How the community answered
(36 responses)- B3% (1)
- C94% (34)
- D3% (1)
Why each option
To create a new branch from an existing one in Git, the `git checkout -b <new-branch-name> <starting-point-branch>` command is used.
The arguments are in the wrong order; `RELEASE` is given as the new branch name and `BUGFIX` as the starting point, which is incorrect.
The `-t` (or --track) option is used to set up tracking for a remote branch, not to create a new local branch from another local branch.
The command `git checkout -b BUGFIX RELEASE` correctly creates a new branch named `BUGFIX` and switches to it, using the current state of the `RELEASE` branch as its starting point.
Similar to B, `-t` is for tracking remote branches and the order of arguments is incorrect for creating a local branch from another.
Concept tested: Git branch creation from an existing branch
Source: https://git-scm.com/docs/git-checkout#_create_new_branches
Topics
Community Discussion
No community discussion yet for this question.