Reputation: 718
I've been working on a project and my computer shut down as though I unplugged it. The software that I was using did an auto save, but it created some problems. Since then I tried to fix it, but it is going to get very ugly if I force it. I have also added files and possibly deleted files.
Is it possible to restore the whole project to my last commit? I don't care about the files I added; they were added just for the purpose of trying to fix the issue, and I'd like those to go away with the recovery. What is the best way to do this in sourcetree.
Upvotes: 0
Views: 120
Reputation: 15139
Whatever you have now - save it! Use git stash
, or just make a new branch and commit it. You may want to use these files later.
Once you've made a backup, do
git reset --hard
This brings your project folder right to the state it was on the last commit.
If you're unfamiliar with console/command line, there must be an option in atlassian sourcetree to do just the same. Search help for "git reset hard".
Also, read this to understand what's going on: Can you explain what "git reset" does in plain english?
Upvotes: 2