How to Find a Deleted File in Commit History

AuthorSumit Dey Sarkar

Pubish Date01 Feb 2024

categoryGit

In this tutorial, we will learn how to find a deleted file in commit history.

How to Find a Deleted File in Commit History

How to find a deleted file in commit history

To find a deleted file in Git commit history, you can use the following command:

git log --all --full-history -- <file_path>

Replace <file_path> with the path to the deleted file. This command use to shows the commit history for the specified file, including commits where the file was deleted. The --all flag ensures that all branches are considered, and --full-history ensures that Git follows the full history, including file renames.

If you want to see the content of the deleted file in a specific commit, you can use:

git show <commit_hash>:<file_path>

Replace <commit_hash> with the commit hash you obtained from the git log command, and <file_path> with the path to the deleted file.

Remember that Git doesn't keep a record of where a file was deleted. It only tracks the changes made to files, so you'll need to look for the last commit where the file was present.

Comments 0

Leave a comment