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
11k stars 547 forks source link

Bad tree object on git gc #264

Open kosmodisk opened 6 years ago

kosmodisk commented 6 years ago

Hello

I am trying to migrate SVN to GIT and while I'm at it, remove unwanted stuff.

Here's what I am doing:

cd PROJECTDIR

git svn init SVNURL --no-metadata
git config svn.authorsfile ../authors.txt
git svn fetch
git remote add origin GITURL

# convert to bare repo according to https://stackoverflow.com/a/2200662/2494723
mv .git ../PROJECTDIR.git
cd ..
git --git-dir=PROJECTDIR.git config core.bare true
rm -rf PROJECTDIR
mv PROJECTDIR.git PROJECTDIR # for simplicity
cd PROJECTDIR

# remove dir
bfg --delete-folders "{REMOVEDIR}" --no-blob-protection
git reflog expire --expire=now --all
git gc --prune=now --aggressive

But gc says that:

Counting objects: 14729, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (13697/13697), done.
Writing objects: 100% (14729/14729), done.
Total 14729 (delta 5178), reused 0 (delta 0)
error: Could not read 7520368faface654668a0c6c009764ea1a015c8b
fatal: bad tree object 7520368faface654668a0c6c009764ea1a015c8b
error: failed to run prune

What is wrong?

rtyley commented 6 years ago

It's possible (tho' a bit unlikely) that the BFG is creating bad tree objects ('tree' is another word for directory or folder) , but it's also possible that the bad tree object is there before the BFG was run.

On a fresh copy of your pre-BFG git repo, try running the exact same prune command and seeing if the same error occurs.

On 21 Feb 2018 2:31 pm, "Sven Süld" notifications@github.com wrote:

Hello

I am trying to migrate SVN to GIT and while I'm at it, remove unwanted stuff.

Here's what I am doing:

cd PROJECTDIR

git svn init SVNURL --no-metadata git config svn.authorsfile ../authors.txt git svn fetch git remote add origin GITURL

convert to bare repo according to https://stackoverflow.com/a/2200662/2494723

mv .git ../PROJECTDIR.gitcd .. git --git-dir=PROJECTDIR.git config core.bare true rm -rf PROJECTDIR mv PROJECTDIR.git PROJECTDIR # for simplicitycd PROJECTDIR

remove dir

bfg --delete-folders "{REMOVEDIR}" --no-blob-protection git reflog expire --expire=now --all git gc --prune=now --aggressive

But gc says that:

Counting objects: 14729, done. Delta compression using up to 4 threads. Compressing objects: 100% (13697/13697), done. Writing objects: 100% (14729/14729), done. Total 14729 (delta 5178), reused 0 (delta 0) error: Could not read 7520368faface654668a0c6c009764ea1a015c8b fatal: bad tree object 7520368faface654668a0c6c009764ea1a015c8b error: failed to run prune

What is wrong?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rtyley/bfg-repo-cleaner/issues/264, or mute the thread https://github.com/notifications/unsubscribe-auth/AADLRjC8A7Cr2qfCzYNBwa6KBn0S3_Mpks5tXCizgaJpZM4SNuqN .

kosmodisk commented 6 years ago

Nope, simple gc ran just fine.

Tried to run without no-blob-protection, no error. So workaround would be - delete manually, commit, run without no-blob-protection?

kosmodisk commented 6 years ago

Ok, this worked for me. Since I'm migrating from svn repo I cannot do straight away as bfg page says, so:

1) git svn checkout 2) delete dirs manually, commit 3) cd into "bare repo" (that is - cd .git) 4) bfg delete folders without no-blob-protection

bfg --delete-folders "{REMOVEDIR}" .

5) gc & push:

git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push