4

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?

Vy Do
  • 46,709
  • 59
  • 215
  • 313
Tom
  • 1,965
  • 3
  • 25
  • 33
  • There are no more efficient way than git command. Let's do it by command line interface. You should add more information or edit it for clear. – Vy Do Dec 26 '19 at 02:25

3 Answers3

5

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:

  1. In "Version Control > Log" view select the commit (search box helps to find it)
  2. In box on right hand side (file tree) select all files to recover
  3. 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):

  1. List all deleted files in repo: git log --diff-filter=D --summary | grep delete
  2. Find deleting commit for one of those files: git rev-list -n 1 HEAD -- [deleted-filename]
  3. Continue with steps of Case 1 above
Tom
  • 1,965
  • 3
  • 25
  • 33
0

Using IntelliJ's Local history module link should help you solve your problem. As long as you haven't invalidated caches or installed a new version of the IDE, it should have a revision of before you deleted the files.

(It also has a retention period for revisions, so I hope you didn't delete the files too long ago)

cb4
  • 6,689
  • 7
  • 45
  • 57
Kelo
  • 1,783
  • 2
  • 9
  • 21
0

Finding past deleted files is not proposed natively in IntelliJ IDEA, and the local history might not have always those files memorized.

That means you need to configure a git bash terminal in IDEA, that you can call on:

https://intellij-support.jetbrains.com/hc/user_images/iyR-p8G0kk2P9HahxoUAwQ.png

Using: c:\Program Files\Git\bin\bash.exe

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250