Search code examples
gitatlassian-sourcetree

Restore Deleted Files from SourceTree or Git


I have recently started using SourceTree to work with Bitbucket. I was working on a project, and then I decided I needed to move it to a different folder (for various reasons). So, I cut the files that I was working on in the repo, and then clicked the delete button in SourceTree, not realising that doing this would actually delete the files. I cut the files just in case, but didn't remember that pasting these files requires the original files to exist.

Now, I only have the files left from repo that SourceTree did not delete.. these are the files in the objects directory, and I do not have the info or pack folders that are inside the objects directory.

Is there any way that I can restore the files? I have taken a look at this question and this question, however I am new to git and cannot figure out how to actually do these.

Please help! How can I restore the files in the repo?


Solution

  • If that files were committed you can just make git checkout HEAD -f.
    If files were not committed they are not stored as objects.