nerdexam
Microsoft

AZ-400 · Question #427

Drag and Drop Question You use Git for source control. You delete a file, commit the changes, and continue to work. You need to recover the deleted file. Which three commands should you run in sequenc

The correct answer is git log; git checkout [hash]~1 --path/to/file; git commit -m 'undeleted the file'. To recover a deleted file in Git after committing the deletion, you first run 'git log' to find the commit hash where the file still existed. Then 'git checkout [hash]~1 --path/to/file' checks out the file from the commit just before the deletion (the tilde-1 notation means 'one

Submitted by femi9· Mar 6, 2026Configure and manage source control using Git - specifically recovering deleted files from commit history (Azure DevOps AZ-400 / DevOps Engineering)

Question

Drag and Drop Question You use Git for source control. You delete a file, commit the changes, and continue to work. You need to recover the deleted file. Which three commands should you run in sequence? To answer, move the appropriate commands from the list of commands to the answer area and arrange them in the correct order. Answer:

Exhibit

AZ-400 question #427 exhibit

Answer Area

Drag items

git commit -m 'undeleted the file'git loggit checkout [hash]~1 --path/to/filegit taggit restore path/to/filegit stash

Correct arrangement

  • git log
  • git checkout [hash]~1 --path/to/file
  • git commit -m 'undeleted the file'

Explanation

To recover a deleted file in Git after committing the deletion, you first run 'git log' to find the commit hash where the file still existed. Then 'git checkout [hash]~1 --path/to/file' checks out the file from the commit just before the deletion (the tilde-1 notation means 'one commit before the specified hash'). Finally, 'git commit -m' stages and commits the recovered file back into the repository's history.

Topics

#Git#Source Control#Version History#File Recovery

Community Discussion

No community discussion yet for this question.

Full AZ-400 Practice