Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Recover specific data by using Git commands

A worked example

Multiple answers

A committed line in src/settings.py sets an incorrect timeout value. A developer has unstaged changes to other lines in src/settings.py that must remain unchanged. There are no staged changes, and the timeout line has not been edited since the current commit. The current branch must not receive any new commits.

The developer must:

  1. Identify the commit and the author that last changed the timeout line.
  2. View the complete content of src/settings.py as it was at that commit.

Which two commands should the developer use? Each correct answer presents part of the solution.

Choose 2 answers.
Why

git blame identifies the commit and author associated with the timeout line's last change. git show then displays the complete file from that commit without changing the working tree or adding a commit. File checkout and restore would replace local content, while cherry-pick applies changes to the branch. Reflog does not provide the required line attribution or file content.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free