Find when and by whom a file was deleted in Git

Locate deletion commits, inspect author and committer metadata, recover the previous contents, and choose between restoring one file and reverting a whole commit.

Best practices
Illustration of Git branches and version history

Filter a file's history for deletions, then inspect the matching commit:

git log --diff-filter=D --format='%h | %an | %ad | %s' \
  --date=iso -- path/to/file

Each result includes a commit ID, author name, author date, and subject. A path can be deleted, restored, and deleted again, so there may be several matches. Git log normally lists newer commits first; the last displayed result is not automatically the most recent deletion.

Inspect the deletion in context

git show COMMIT
git show --stat COMMIT
git show --no-patch --format=fuller COMMIT

Replace COMMIT with an actual deletion commit. The full diff shows what else changed, while --stat provides a file summary. The fuller format separates author and committer metadata: authorship, integration, and the date someone pushed the commit are different facts. Commit metadata alone is not proof of who physically deleted a file or pushed the change.

Use the commit ID to find an associated pull request, merge request, or CI run when the message does not explain the decision.

Inspect the file before deletion

For an ordinary single-parent deletion:

git show COMMIT^:path/to/file
git blame COMMIT^ -- path/to/file

^ selects the first parent. Blame identifies the last recorded change to each surviving line in that parent snapshot; it does not establish why the file was deleted. For merge commits, compare the relevant parents rather than assuming the first parent contains the version you need.

Restore one file or undo the entire commit

To recover just the file:

git restore --source=COMMIT^ -- path/to/file
git add -- path/to/file
git commit -m "Restore accidentally deleted file"

To reverse all changes made by the deletion commit, use git revert COMMIT instead. Choose that only when you want to undo its other changes too; reverting a merge requires an explicit mainline decision and can affect later merges.

FAQ

Could the file have been renamed?

Use git log --follow --name-status -- path/to/file for a single path. Rename detection can show entries such as R100 old-name new-name, where the score describes content similarity. Use the historical path when examining older revisions.

How can I narrow the time range?

git log --diff-filter=D --since='2026-06-01' --until='2026-09-01' \
  -- path/to/file

Interpret date filters with the repository's timestamp and timezone context; use precise timestamps when the boundary matters.

What if the deletion is on another branch?

Add --all to search history reachable from local refs. Fetch the relevant remote branches first if their history is missing locally.

See git-log, git-show, git-blame, and git-revert.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting