You could try and:
clone your BitBucket repo again
add in that new clone a remote referencing your current local clone
git remote add corrupt/path/to/your/first/cloned/repo
git pull corrupt
, and thengit push
That being said, after using git fsck
for confirmation, you can try and solve that corrupt object.
As usual, make a backup of that local repo first.
After discussion, it turns out that:
the corrupt repo is a shallow one (cloned that way automatically by a tool).
That means you can clone it easily, even when you do arm .git/shallow
, as suggested here.one way to unshallow a shallow repo is to unpack a fresh repo and copy over the
.git/objects/pack
folder to the corrupted repo:git clone git@bitbucket.org:username/reponame.git repo2 mkdir packs cp repo2/.git/objects/packs/* packs cd repos2 git unpack-objects < ../packs/*.pack cd .. cp -r repo2/.git/objects/* corrupt/.git/objects/
That will remove any error due to legacy unpacked object being corrupted by the
sed
command, but that won't fix the ones done since that clone.
For a corrupted repo, the usual commands are listed in this answer and this comment.
In the end, the OP had:
git fsck --full
error: corrupt loose object '3ddb67eb5343e75ac36656c86c4386f8dd117df4'
fatal: loose object 3ddb67eb5343e75ac36656c86c4386f8dd117df4 (stored in .git/objects/3d/db67eb5343e75ac36656c86c4386f8dd117df4) is corrupt
(no more:
error: inflate: data stream error (incorrect data check)
error: sha1 mismatch ...
which were because of legacy commit corrupted)
For solving that, one can try and follow "Documentation/howto/recover-corrupted-blob-object.txt
".
That being said, if that doesn't pan out, it is easier to at least group all last commits into one:
git clone git@bitbucket.org:username/reponame.git repo2
cd repo2
git --work-tree=../corrupt add -A .
git commit -m "last changes"
git push
One can try and rebuild all 12 commits, but that isn't obvious to do, especially when multiple modifications are done within one file.