Don
Don

Reputation: 4202

Restore broken branch/resolve detached HEAD state?

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?

Upvotes: 3

Views: 4004

Answers (1)

Don
Don

Reputation: 4202

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.

Upvotes: 5

Related Questions