Developing Applications and Automating Workflows Using Cisco Platforms (DEVASC) — Question 379
A file in a local Git repository has been updated and issued the git add . command. The git diff command has been run to compare the changes to the previous commit, but nothing shows. Which action identifies the problem?
Answer options
- A. Run the git add . command again in the correct subdirectory to ensure changes added to the staging area.
- B. Run the git commit command before the differences are compared to receive the end state of the code.
- C. Run the git status command to see the differences between current and previous code review stages.
- D. Run the git diff --staged command to compare the code added to the staging area.
Correct answer: D
Explanation
The correct answer is D because the git diff --staged command shows the differences between the staged changes and the last commit. Option A is incorrect as running git add . again does not address the comparison needed. Option B is also wrong because committing does not help identify what was staged. Option C, while useful, does not provide the specific comparison between the staged changes and the last commit.