nerdexam
Cisco

200-901 · Question #538

A developer is working on an existing feature that needs enhancing. The primary production branch for the application is 'prim4a3b8c6d80374' and the branch for working on the feature is 'feat145678909

The correct answer is D. git clone [url] - -branch feat145678909 - -single-branch. To clone a specific Git branch and restrict the clone to only that branch's history, the git clone command requires both the --branch and --single-branch options.

Software Development and Design

Question

A developer is working on an existing feature that needs enhancing. The primary production branch for the application is 'prim4a3b8c6d80374' and the branch for working on the feature is 'feat145678909'. The developer needs to create a clone of the single branch used for the feature that only has commits included in the current line of history. Which Git command must be used?

Options

  • Agit clone [url] - -feat145678909 - -single-branch
  • Bgit clone [url] - -branch feat145678909 - -single
  • Cgit clone [url] - -single-branch feat145678909
  • Dgit clone [url] - -branch feat145678909 - -single-branch

How the community answered

(20 responses)
  • B
    5% (1)
  • C
    5% (1)
  • D
    90% (18)

Why each option

To clone a specific Git branch and restrict the clone to only that branch's history, the `git clone` command requires both the `--branch` and `--single-branch` options.

Agit clone [url] - -feat145678909 - -single-branch

This option uses incorrect syntax for specifying the branch name directly after a double-hyphen, which is not how `git clone`'s `--branch` option works.

Bgit clone [url] - -branch feat145678909 - -single

The `--single` option is not a valid Git command line option for `git clone`; the correct option is `--single-branch`.

Cgit clone [url] - -single-branch feat145678909

This option places the branch name as an argument to `--single-branch`, but the branch name should be specified using the `--branch` option.

Dgit clone [url] - -branch feat145678909 - -single-branchCorrect

The `git clone` command with the `--branch <branch_name>` option specifies which branch to check out, and the `--single-branch` option ensures that only the history of that specific branch is cloned, reducing the repository size and transfer time.

Concept tested: Git clone single branch

Source: https://git-scm.com/docs/git-clone

Topics

#Git#Version Control#git clone#Branching

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice