Search code examples
pythongithubpycharmbackuprecover

recover deleted script when used 'git checkout filename'


I was having trouble pushing my file to a repo, so I read to use:

'git checkout filename' 

and now my script is gone.

Is there a backup section in pycharm or github where I can recover this script? How else could I recover this file, I've read some other posts but don't fully understand and don't want to put any more commands in case I make it worse.

Thanks


Solution

  • Using git, might not possible.

    But using Pycharm, Luckily it is possible. You can use its builtin local history feature to bring it back from dead.

    Just right click your project name from project section (left panel) > Local History > Show History. Locate your file from that popup window and just click the revert button revert button

    Note: You can verify that file changes will be listing a "deleting" history, and after pressing revert button it will show up in your project section.

    See details here