3

After restarting my computer, 'git commit' & 'git status' both return an error message:

error: bad signature

fatal: index file corrupt

running 'git branch':

fatal: Failed to resolve HEAD as a valid ref.

running 'git log':

fatal: your current branch appears to be broken


What causes this? How can I restore/fix my local repo/branch?

1 Answer 1

5

I found a solution that worked for me.

  1. Re-clone the repository into another directory.
  2. Copy the .git folder from newly cloned repo & replace the one in the original repo.

This will repair the detached HEAD state which occurred as a result of (in this particular case) uncommitted changes that were discarded (but saved locally) when computer was forced to shut down.

Sign up to request clarification or add additional context in comments.

2 Comments

Where can I find the .git folder from the newly cloned repo?
It should be in the root directory of your repository. Depending on your settings and what you are using (file explorer or terminal) it may be hidden.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.