Question 520
Multiple small feature commits should appear as one combined change during integration. Which Git technique supports this?
- Annotated tag
- git rebase main
- git config --local user.email admin@example.org
- git switch -c experiment
- Squash merge
- 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?
- git add config.yml
- git commit -m 'Update config'
- git status
- 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?
- git fetch origin
- git clone repository-url
- git log --oneline
- 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?
- git init
- git commit -m 'Update config'
- git add config.yml
- 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?
- .gitignore
- git commit -m 'Update config'
- git init
- 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?
- Squash merge
- git switch -c experiment
- Annotated tag
- git merge feature
- 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?
- git stash push
- git diff
- git restore --staged config.yml
- 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?
- git merge feature
- Squash merge
- git switch -c experiment
- 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?
- git status
- git commit -m 'Update config'
- git add config.yml
- 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?
- git merge feature
- Squash merge
- git rebase main
- 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?
- git stash push
- git reset --mixed HEAD~1
- git restore --staged config.yml
- 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.