PC crashed on commit and lost local workspace

Hello,

I'm a bit on panic mode at the moment. This is what happened: I just got a blue screen on my PC right when I was doing a commit into a local branch.

After restarting the PC I openend SourceTree and saw that I was checked out at the master branch instead of the branch in which I was working before the crash. What's more, the branch has disappeared completely and I have no local history at all.

The good news is that it looks like all the changes that I had made are still there. I see all the files in "Staged changes", but I need to stash them before I can switch to another branch (as I don't want to commit to master yet) and I'm getting the following error:

git -c diff.mnemonicprefix=false -c core.quotepath=false stash save AfterCrash

fatal: bad revision 'HEAD'

fatal: bad revision 'HEAD'

fatal: Needed a single revision

You do not have the initial commit yet

Completed with errors, see above.

Is there a way to recover the status of my workspace before the crash? What would be the best way to solve this issue?
I will really appreciate any help. Thank you!

2 answers

1 accepted

Well in the end I decided to start from scratch and clone the remote repo again.

Then I replaced the files by mine and now I can confirm that all the modifications are there. That was close :-D

You could solve that error by applying the following command:

git symbolic-ref HEAD refs/heads/name-of-the-branch-you-were-on

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

67 views 0 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you