CompTIA XK0-006 (CompTIA Linux+) Practice Test 53

Question 520

Multiple small feature commits should appear as one combined change during integration. Which Git technique supports this?

  1. Annotated tag
  2. git rebase main
  3. git config --local user.email admin@example.org
  4. git switch -c experiment
  5. Squash merge
  6. git merge feature

Explanation

Correct Answer

E:

A squash merge combines changes into a single staged result for one new commit. It does not preserve every feature commit as a separate ancestor on the target branch.

Incorrect Answers

A:

An annotated tag references a revision and can include a message and author metadata; its scope differs from collapsing a feature series into one integrated commit, so it cannot meet the stated requirement.

B:

Rebase reapplies commits onto another base and rewrites their identities; that is not equivalent to collapsing a feature series into one integrated commit.

C:

Local Git configuration is stored in the repository and overrides broader user settings; the administrator instead needs collapsing a feature series into one integrated commit; this option serves a different purpose.

D:

git switch -c creates the named branch at the current commit and checks it out; it answers a neighboring question rather than collapsing a feature series into one integrated commit.

F:

git merge integrates the named branch into the current branch history; this does not achieve collapsing a feature series into one integrated commit on the system described.

Question 521

A previously unmanaged project folder should become a new local Git repository. Which command does this?

  1. git add config.yml
  2. git commit -m 'Update config'
  3. git status
  4. git init

Explanation

Correct Answer

D:

git init creates the .git metadata required for version control. It does not automatically publish to a remote server.

Incorrect Answers

A:

git add updates the index for the specified paths; this does not achieve initializing a local repository on the system described.

B:

git commit records the staged snapshot in the local repository history; it will not provide initializing a local repository under these conditions.

C:

git status reports working tree and staging-area differences against the current commit; using it would leave initializing a local repository unresolved.

Question 522

An administrator needs to set the author identity used for future commits in this repository only. Which setting scope fits?

  1. git fetch origin
  2. git clone repository-url
  3. git log --oneline
  4. git config --local user.email admin@example.org

Explanation

Correct Answer

D:

Local Git configuration is stored in the repository and overrides broader user settings. It affects commit identity metadata, not server authentication credentials.

Incorrect Answers

A:

git fetch updates remote-tracking references and objects without updating the checked-out branch's working files; the evidence calls for configuring repository-local commit identity, not merely this separate operation.

B:

git clone creates a local repository from a remote source with fetched history and default branch; the task involves configuring repository-local commit identity, whereas this addresses another subsystem.

C:

git log displays revisions, and --oneline formats abbreviated commit identifiers with subjects; its scope differs from configuring repository-local commit identity, so it cannot meet the stated requirement.

Question 523

The staged changes should become a local versioned revision with a message. Which command does that?

  1. git init
  2. git commit -m 'Update config'
  3. git add config.yml
  4. git status

Explanation

Correct Answer

B:

git commit records the staged snapshot in the local repository history. Pushing is a separate operation for sharing it remotely.

Incorrect Answers

A:

git init creates the .git metadata required for version control; it answers a neighboring question rather than creating a commit from staged content.

C:

git add updates the index for the specified paths; this does not achieve creating a commit from staged content on the system described.

D:

git status reports working tree and staging-area differences against the current commit; it will not provide creating a commit from staged content under these conditions.

Question 524

A particular file is ready to be included in the next commit, but other changes should stay unstaged. Which command stages it?

  1. .gitignore
  2. git commit -m 'Update config'
  3. git init
  4. git add config.yml

Explanation

Correct Answer

D:

git add updates the index for the specified paths. Staged content is not yet permanently recorded as a commit.

Incorrect Answers

A:

.gitignore patterns suppress matching untracked paths from normal addition; the requirement is staging one file for the next commit, outside the effect of this choice.

B:

git commit records the staged snapshot in the local repository history; it does not deliver staging one file for the next commit, which is decisive in this scenario.

C:

git init creates the .git metadata required for version control; the evidence calls for staging one file for the next commit, not merely this separate operation.

Question 525

A release branch needs a human-readable immutable reference to a specific commit, often used for version labeling. Which Git object is suitable?

  1. Squash merge
  2. git switch -c experiment
  3. Annotated tag
  4. git merge feature
  5. git rebase main

Explanation

Correct Answer

C:

An annotated tag references a revision and can include a message and author metadata. It is commonly used to mark releases.

Incorrect Answers

A:

A squash merge combines changes into a single staged result for one new commit; that is not equivalent to labeling a specific release commit.

B:

git switch -c creates the named branch at the current commit and checks it out; the administrator instead needs labeling a specific release commit; this option serves a different purpose.

D:

git merge integrates the named branch into the current branch history; that changes a different part of the system; the requested outcome is labeling a specific release commit.

E:

Rebase reapplies commits onto another base and rewrites their identities; this does not achieve labeling a specific release commit on the system described.

Question 526

A local branch's last commit needs to be undone while preserving changes in the working directory for repair. Which command fits?

  1. git stash push
  2. git diff
  3. git restore --staged config.yml
  4. git reset --mixed HEAD~1

Explanation

Correct Answer

D:

A mixed reset moves the current branch and resets the index while retaining tracked working-tree changes. History rewriting on shared branches is risky.

Incorrect Answers

A:

Stash saves eligible working-tree and index changes in a local stack for later application; it will not provide moving back one commit while keeping file edits under these conditions.

B:

git diff examines file changes, whereas git reset --mixed moves HEAD and resets the index while retaining worktree edits. --cached instead inspects staged differences against the commit; using it would leave moving back one commit while keeping file edits unresolved.

C:

Restore with --staged resets the index entry to the current commit while preserving working-tree edits; the requirement is moving back one commit while keeping file edits, outside the effect of this choice.

Question 527

A local feature branch should replay its commits on top of the latest main history before publication. Which command fits?

  1. git merge feature
  2. Squash merge
  3. git switch -c experiment
  4. git rebase main

Explanation

Correct Answer

D:

Rebase reapplies commits onto another base and rewrites their identities. Avoid rebasing commits already shared without coordinating collaborators.

Incorrect Answers

A:

git merge integrates the named branch into the current branch history; the task involves replaying local work onto a new base, whereas this addresses another subsystem.

B:

A squash merge combines changes into a single staged result for one new commit; its scope differs from replaying local work onto a new base, so it cannot meet the stated requirement.

C:

git switch -c creates the named branch at the current commit and checks it out; that is not equivalent to replaying local work onto a new base.

Question 528

A maintainer wants to see which tracked files have changed and which untracked files exist. Which command fits?

  1. git status
  2. git commit -m 'Update config'
  3. git add config.yml
  4. git init

Explanation

Correct Answer

A:

git status reports working tree and staging-area differences against the current commit. It does not modify the repository.

Incorrect Answers

B:

git commit records the staged snapshot in the local repository history; this does not achieve inspecting working tree and index state on the system described.

C:

git add updates the index for the specified paths; it will not provide inspecting working tree and index state under these conditions.

D:

git init creates the .git metadata required for version control; using it would leave inspecting working tree and index state unresolved.

Question 529

An engineer wants a new branch for a risky experiment while retaining the main branch. Which command creates and switches to it?

  1. git merge feature
  2. Squash merge
  3. git rebase main
  4. git switch -c experiment

Explanation

Correct Answer

D:

git switch -c creates the named branch at the current commit and checks it out. Edits can then be isolated from the previous branch.

Incorrect Answers

A:

git merge integrates the named branch into the current branch history; it does not deliver isolating work on a newly created branch, which is decisive in this scenario.

B:

A squash merge combines changes into a single staged result for one new commit; the evidence calls for isolating work on a newly created branch, not merely this separate operation.

C:

Rebase reapplies commits onto another base and rewrites their identities; the task involves isolating work on a newly created branch, whereas this addresses another subsystem.

Question 530

The operator must inspect which lines changed in unstaged tracked files since the index snapshot. Which command fits?

  1. git stash push
  2. git reset --mixed HEAD~1
  3. git restore --staged config.yml
  4. git diff

Explanation

Correct Answer

D:

By default git diff presents tracked changes that have not yet been staged, without altering either file contents or index. --cached instead inspects staged differences against the commit.

Incorrect Answers

A:

Stash saves eligible working-tree and index changes in a local stack for later application; the administrator instead needs viewing unstaged textual differences; this option serves a different purpose.

B:

A mixed reset moves the current branch and resets the index while retaining tracked working-tree changes; it answers a neighboring question rather than viewing unstaged textual differences.

C:

Restore with --staged resets the index entry to the current commit while preserving working-tree edits; that changes a different part of the system; the requested outcome is viewing unstaged textual differences.

CompTIA Linux+ (XK0-006) Practice Tests