Antwan Kakki
Antwan Kakki

Reputation: 250

Git fetch interrupted and corrupted repository

I ran git fetch and my laptop died while it was running. Now there is a .git folder but running any git command says fatal: Not a git repository (or any of the parent directories): .git. Running git init says Reinitialized existing Git repository in <directory>

Upvotes: 1

Views: 210

Answers (1)

cryptarch
cryptarch

Reputation: 199

You certainly don't want to run git init if the repository already exists somewhere. Whenever the repository already exists you either want to clone it or fetch it.

The way to handle this situation depends on whether you had local changes that have not been pushed out to a remote yet.

The simplest case is that you had no changes (or you are willing to discard any local changes). In that case you can simply delete the entire entire directory and do a git clone <remote> from scratch to grab a pristine copy.

If you had important local changes then the comment offered by @torek should be your starting point, it should be converted to an Answer ;)

Upvotes: 1

Related Questions