Reputation: 830
I'm trying to recover a file that is no longer in a Git repository.
I can see that the file was created for sure when I run this:
git log --all --full-history --diff-filter=A --summary | grep filename
But I can't find when the file was deleted with this:
git log --all --full-history --diff-filter=D --summary | grep filename
The file for sure isn't there anymore, so why wouldn't it show up?
Upvotes: 1
Views: 4435
Reputation: 45819
UPDATED based on comments.
So the first thing was making sure that the diff-filter
wasn't deceiving you, because if git sees the file as "moved" or "renamed" then diff-filter
of D
won't capture that. But even taking the diff-filter
out of the equation doesn't show the file being moved or removed.
That means it has never been moved or removed. If you don't see it in the work tree, then either
(1) Removal of the file is staged but not committed (2) Removal of the file is untracked (3) The file was never on the current branch
I'm betting on (3). The command you used to find the "create" record searches the history of all refs. Take out the --all
argument and ask for the history of your current commit
git log --full-history --diff-filter=A --summary | grep filename
Do you still see the file being created? If not, then it was committed only on a different branch. For example, if you have
x --- x --- H <--(master)
\ ^HEAD
A --- x <--(develop)
perhaps the file was added in commit A
, which you would see in the history of develop
(or when using --all
). But of course the file would not be in H
(which is what you'd have checked out in this scenario) or its history. So it wasn't deleted.
If the file is created in the current commit's history, but is never removed, then it's in the current commit. The only reason left why you'd not see it is if it's been removed from the work tree, but the delete would be not yet committed and maybe not yet added.
Upvotes: 4