nerdexam
CompTIA

XK0-004 · Question #505

A Linux administrator needs to update a script that is stored in the team's Git repository. After the administrator clones the repository, which of the following is the BEST method to ensure merging c

The correct answer is D. Create a new branch and make modifications to the code. When collaborating on a shared Git repository, creating a separate branch isolates your changes and enables a controlled merge process that preserves all contributors' work.

Scripting, Containers and Automation

Question

A Linux administrator needs to update a script that is stored in the team's Git repository. After the administrator clones the repository, which of the following is the BEST method to ensure merging changes in the future will not overwrite other users' commits to the repository?

Options

  • ACreate a new repository based on the existing repository
  • BCreate a new folder with the changes under the administrator's name
  • CCreate a new script and commit it to the master branch
  • DCreate a new branch and make modifications to the code

How the community answered

(42 responses)
  • A
    2% (1)
  • B
    7% (3)
  • C
    2% (1)
  • D
    88% (37)

Why each option

When collaborating on a shared Git repository, creating a separate branch isolates your changes and enables a controlled merge process that preserves all contributors' work.

ACreate a new repository based on the existing repository

Forking or creating a new repository severs the shared history and makes synchronizing upstream changes unnecessarily complex, defeating the purpose of a shared team repository.

BCreate a new folder with the changes under the administrator's name

Adding a folder named after the administrator is not a version-control strategy - it duplicates files outside of Git's branching model and does not prevent merge conflicts.

CCreate a new script and commit it to the master branch

Committing directly to the master branch bypasses any review process and risks overwriting or conflicting with commits other team members have already pushed.

DCreate a new branch and make modifications to the codeCorrect

Creating a new branch gives the administrator an isolated workspace where commits do not interfere with the main branch or other contributors' commits. When the work is ready, it can be merged via a pull or merge request, which Git tracks per-commit so no other user's history is lost. This is the standard Git collaboration workflow designed specifically to prevent overwriting concurrent changes.

Concept tested: Git branching workflow for collaborative development

Source: https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell

Topics

#Git branching#version control#merge conflicts#collaboration workflow

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice