Skip to content

Git Repo Fixes

It looks like you’re experiencing a Git repository corruption issue. Specifically, you have a corrupt loose object that’s preventing Git from properly functioning. Let’s fix this issue step by step:

  1. First, the error is with this specific Git object: 54d217778312cc3358d29c5d2f9726493ac99fd0

  2. The git fsck command has identified both the corrupt object and several dangling blobs (objects not connected to any commit).

Here’s how to recover from this situation:

  1. Remove the corrupt object:

    Terminal window
    rm .git/objects/54/d217778312cc3358d29c5d2f9726493ac99fd0
  2. Create a new repository and copy clean commits:

    Terminal window
    cp -r ./ ../project-backup
    Terminal window
    mkdir ../new-repo
    cd ../new-repo
    git init
    Terminal window
    cd ../Around

    Try to create a bundle excluding the corrupt object

    Section titled “Try to create a bundle excluding the corrupt object”
    Terminal window
    git bundle create ../repo.bundle --all
    Terminal window
    git for-each-ref --format="%(refname)" | xargs -n 1 git bundle create ../repo.bundle
    Terminal window
    cd ../new-repo
    git pull ../repo.bundle
  3. If bundle approach fails, try this alternative:

    Terminal window
    # In your original repo directory:
    git show-ref > ../refs-backup.txt
    # Create a new repo
    mkdir ../fixed-repo
    cd ../fixed-repo
    git init
    # Copy all good files from original repo
    mkdir -p .git/objects
    find ../Around/.git/objects -type f -name "[0-9a-f][0-9a-f]*" | \
    grep -v "54d217778312cc3358d29c5d2f9726493ac99fd0" | \
    while read file; do cp "$file" ".git/objects/$(basename $(dirname $file))/"; done
    # Copy refs
    cp -r ../Around/.git/refs .git/
    # Run git fsck to check new repo integrity
    git fsck
  4. If no important data is at risk, the simplest solution might be:

    Terminal window
    # Clone fresh from remote (if available)
    git clone <your-repository-url> ../fresh-repo
    # Or initialize a new repo and add your files
    mkdir ../new-start
    cd ../new-start
    git init
    cp -r ../Around/* .
    rm -rf .git
    git init
    git add .
    git commit -m "Fresh start after repository corruption"

Would you like me to explain any of these approaches in more detail or would you like to try a different recovery method?