I have deleted files in my project, committed that and done other commits since then.
Now I need about 15 of those files. There are answers (like the question) on how to do this using git command line.
How can I do the same thing in IntelliJ IDEA?
I found a way for both situations, either knowing the deleting commit or not even knowing it.
Case 1: Let’s start with the easier one, where I do know the commit:
- In “Version Control > Log” view select the commit (search box helps to find it)
- In box on right hand side (file tree) select all files to recover
- Right-click and “Revert selected changes”
Case 2: Now if I don’t know the deleting commit I can either try to narrow the commit log down using the “Paths” filter option. Or I can run these shell commands to get the exact commit (and search that in git log):
- List all deleted files in repo:
git log --diff-filter=D --summary | grep delete
- Find deleting commit for one of those files:
git rev-list -n 1 HEAD -- [deleted-filename]
- Continue with steps of Case 1 above
Answered By – Tom