my git is broken, how can i get/clone the latest commits from every branch to a new git


Till now i only worked with a local repository. Now i have to push my code also to a bitbucket server. After an error message from bitbucket (fatal: bad tree object 801d94bc0b9cbd6383650ba85fed50c1ac7a143) i do a git fsck on my local repo and get the following result:

Checking object directories: 100% (256/256), done.
broken link from    tree 9aff83ecd679eda74d63ee09fd7946f434b16a6d
              to    blob d7fc5427ee5a9c9d13b4229ed8908b9d7b2f0cf8
broken link from    tree 46ab23a168bedf145a1a4822f75b73855865e3c1
              to    blob 77cbd7c1d5c597392dab0b9d22f0e983241a75bc
broken link from    tree a396e65bdfd6106c2b7ba0ec8c488bd1b79b5b32
              to    tree 801d94bc0b9cbd6383650ba85fed50c1ac7a143a
broken link from    tree 67f2f023c6ed3d5415ec0e55daad1e7c11faf9e0
              to    blob 4f4a032a26c2bbb4a6f0a03f2415af10a55df208
broken link from    tree 001aa703b69f30e7cd599c724762b0c2740caded
              to    blob 5e1c317fbe8f3fe24cc0177a89fc35aca000761b
dangling commit 55403e88e2ebd20d52cb58906fc84fcc7485721c
dangling blob 5d401c73270eda73e3c078612c833773e0b13e7f
dangling blob 7280e634bbfa7ad005033803493a0b03b2f67e9a
dangling blob 62420d66f9b3f5c70b3464fa9e1451266e2f50ae
dangling blob 8d42504462666dd57f58da9444e3e5b249d22cc4
dangling commit 28c321c6e6bd5d5981418d6af5901c7c9b6969da
dangling blob 6e040a6d27c285ab39059d6dbe55327b37af2b43

There are about 100 lines with dangling blobs, commit and broken links. I had several problems with my filesystem over the last years. I have no problem to setup a new git but currently i have about 10 branches which i want to clone into a new git without the history, just the current code.

For the first i tried the following

mkdir gitbak
cd gitbak
git clone /home/debian/myproject/.git
git clone 
// get the master branch
git checkout -b devbranch origin/devbranch

as a result i get this branch also to the new git but i get also all commits from this branch and git fsck brings me also the same errors. How can i get only the lastest commit/snapshot/plain text from each branch into the new one?


6/30/2020 12:05:54 PM