AZ-400 exam dumps

AZ-400 practice question 88 of 306

Designing and Implementing Microsoft DevOps Solutions. Professional level, Microsoft. Free question with the correct answer and a full explanation.

AZ-400 Question 88

Single answer

You�re working on a feature branch for a web application and have already made several commits. In one of these commits, you unintentionally overwrote critical configuration details in 'appsettings.json'. You have the commit hash (abc1234) where the correct configuration last appeared. How can you restore only the old version of 'appsettings.json' from that commit while preserving all other changes made after it?

  1. A

    Use git revert abc1234

  2. B

    Use git checkout abc1234 -- appsettings.json

  3. C

    Use git reset --hard abc1234

  4. D

    Use git cherry-pick abc1234

Show answer and explanation

Correct answer: B

Explanation

When you need to recover specific data for a single file from a previous commit, using the checkout syntax (git checkout -- ) is the straightforward approach. This technique ensures that only the targeted file reverts to its older state, while leaving other files and commits untouched. For more details, consult the official Git documentation: https://git-scm.com/docs/git-checkout.

  • A. Incorrect.

    Incorrect. git revert abc1234 creates a new commit that reverses the changes introduced in that commit. It doesn�t selectively restore a single file; it reverts all changes from that commit, potentially impacting other files you don�t want to revert.

  • B. Correct.

    Correct. git checkout abc1234 -- appsettings.json pulls the version of 'appsettings.json' from commit abc1234, preserving your current branch state for other files. You can then commit the reintroduced file if desired.

  • C. Incorrect.

    Incorrect. git reset --hard abc1234 moves your entire branch pointer back to commit abc1234, discarding all changes after that commit. This loses subsequent work rather than selectively restoring just one file.

  • D. Incorrect.

    Incorrect. git cherry-pick abc1234 applies the entire diff of commit abc1234 to the current HEAD. While it re-applies changes, it doesn�t specifically restore one file from that commit; it reintroduces every change in that commit, which may not be what you want for a single file.

Timed practice exam

Take a AZ-400 practice test under exam conditions

70 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam