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?
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.
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.
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.
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.
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.
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 ...
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With