rtyley / bfg-repo-cleaner

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala
https://rtyley.github.io/bfg-repo-cleaner/
GNU General Public License v3.0
10.86k stars 535 forks source link

Remote refs appear to have been corrupted after running BFG #356

Closed jlevers closed 4 years ago

jlevers commented 4 years ago

First of all, thank you for creating (and open sourcing) this awesome tool!

I successfully removed a number of large objects from my repository with java -jar bfg.jar --delete-files \*.obj path/to/repo. I then realized that I wanted to remove them from the HEAD of master, so I ran the command again with --no-blob-protection.

Afterwards, git reflog expire --expire=now --all ran with no output, but when I run git gc --prune=now --aggressive, it fails with the following error message:

error: refs/remotes/origin/master does not point to a valid object!
error: refs/remotes/origin/restructure does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/remotes/origin/restructure does not point to a valid object!
fatal: bad object refs/remotes/origin/HEAD
error: failed to run repack

I get similar messages when I try to run basically any other Git-related command in the repo. Any idea what happened here?

Thank you!

javabrett commented 4 years ago

Did you clone into a bare repo?

jlevers commented 4 years ago

It was a full repo that I attempted to turn into a bare one like so:

$ cp repo/.git repo.git
$ git config --bool core.bare true

I can't re-clone the remote repo as a bare repo, for a variety of reasons. Although, now that I'm typing this, I realize there's probably a way to clone a local repo into a bare repo. I'm going to look into that now.

javabrett commented 4 years ago

git clone --bare is definitely the way to go.

jlevers commented 4 years ago

Yep, rerunning everything after doing git clone -l --bare path/to/local/repo fixed it. My bad, thank you @javabrett.