Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recover deleted file from PhpStorm and SourceTree

I have an open project in PhpStorm that I manage using SourceTree. I was trying to remove some image files from a commit using SourceTree, but accidentally selected a file that should not be deleted. I haven't changed anything (in either PhpStorm or SourceTree) since deleting the file. I tried to do Ctrl+Z in SourceTree but nothing happened. I then checked in PhpStorm Vcs -> local history, but it didn't show the file. How can I recover this file?

like image 811
Sven van den Boogaart Avatar asked Jul 22 '15 20:07

Sven van den Boogaart


People also ask

Can you restore deleted file in Git?

If you have deleted the file and already committed the changes, you need to use the ` git checkout` command to restore the file. First, you need to find out the checksum of the commit that deleted the file, and then check out the file from the previous commit.

How do I recover a destroyed file?

Right-click the file or folder, and then select Restore previous versions. You'll see a list of available previous versions of the file or folder. The list will include files saved on a backup (if you're using Windows Backup to back up your files) as well as restore points, if both types are available.

How to recover deleted files in Sourcetree?

Right-click on the deleted file and select "Log Selected" menu item. 3. Determine when the file was last committed. 4. Go to that commit 5. Right-click on the deleted file and select "Reset to commit" menu item. Seems like it's a Sourcetree bug that "log selected" is dim in step 2.

Does PhpStorm send deleted files to trash?

I accidentally deleted a whole bunch of files I didn't mean to delete, and it seems that PHPStorm doesn't send deleted files to my Trash, it just deletes them! I tried to undo over and over but at some point I had created a new file and modified it so Undo stops and says I can't undo creating a new file because it's already been modified.

What is local history in PhpStorm?

Built right into PHPStorm is the concept of Local History. Local History can be found by going to VCS on the top bar, and then Local History > Show History. It is contextual, so if you highlight the top level folder of your project, you see all the history for all changes in your folder structure.

How to recover a deleted file in a commit?

To recap what that post said to do: 1 Go to the commit that deleted the files. 2 Right-click on the deleted file and select "Log Selected" menu item. 3 Determine when the file was last committed. 4 Go to that commit 5 Right-click on the deleted file and select "Reset to commit" menu item. More ...


1 Answers

Try to right click on project main folder in phpStorm and select Local history / Show History in context menu (not vcs / local history). The file should be at the list as "Deleting".

like image 51
Ncx Avatar answered Sep 19 '22 10:09

Ncx