Skip to content

Instantly share code, notes, and snippets.

@simonbyrne
Created October 4, 2017 20:46
Show Gist options
  • Save simonbyrne/e8923aec3b27b285789efcd616114a95 to your computer and use it in GitHub Desktop.
Save simonbyrne/e8923aec3b27b285789efcd616114a95 to your computer and use it in GitHub Desktop.
Create a bad git repository
git init --bare gitprob
git clone gitprob gitprobwork
cd gitprobwork
echo "good" > aaaa
GOOD=$(git hash-object -w aaaa)
git add aaaa
git commit -m "1"
rm aaaa
echo "more good" > aaaa
git add aaaa
git commit -m "2"
git push
# hash bad contents
echo "bad" > badfile
BAD=$(git hash-object -w badfile)
cd ..
rm -f gitprob/objects/${GOOD:0:2}/${GOOD:2}
mv gitprobwork/.git/objects/${BAD:0:2}/${BAD:2} gitprob/objects/${GOOD:0:2}/${GOOD:2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment