8

Im getting these errors while doing git fsck --full --no-dangling on the remote repository. (GIT's server)

user@server:/var/git/REPOSITORY.git$ git fsck --full --no-dangling
bad sha1 file: ./objects/15/19d8eeacc8d0cd603bd87d2034508b1ffaffa8_28537991145d7e9d87b68335e9b82c2f788cb4fc
bad sha1 file: ./objects/32/4f425bcfe23d9f38b154427eeb9c800d109365_6df2d745fff22839759b25cc83f8d742c2e64086
bad sha1 file: ./objects/42/9225fd8d895084051189dc6478343d54fe41c8_28537991145d7e9d87b68335e9b82c2f788cb4fc
bad sha1 file: ./objects/46/798e4a01a5a7eaf2b203f6d1634d603497041b_6df2d745fff22839759b25cc83f8d742c2e64086
bad sha1 file: ./objects/bc/fb9d62ac05d5203249caa0e7e9cb5d1c32daba_6df2d745fff22839759b25cc83f8d742c2e64086
bad sha1 file: ./objects/cd/477947092b4f20feba8c37df974027b1864215_6df2d745fff22839759b25cc83f8d742c2e64086
Checking object directories: 100% (256/256), done.
Checking objects: 100% (136737/136737), done.
missing commit 590ebc3ac022491d7f11c483480fa9530adc91e8
missing tree bab1d768f0d4f6a02e0a30a6c446afaeabc4aa71

For every bad sha1 file there is another file that starts with the same name but doesnt have an underscore _ and then some other text. the files have the exact same file size but different date or time.

Example of the two files:

./objects/15/19d8eeacc8d0cd603bd87d2034508b1ffaffa8_28537991145d7e9d87b68335e9b82c2f788cb4fc
./objects/15/19d8eeacc8d0cd603bd87d2034508b1ffaffa8

I'm attaching screen shots of two cases out of the 6 because they are all the same:

Screenshot 1: File1

Screenshot 2: File 2 Can i delete the duplicates, what will happen?

*any ideas on the missing commit\tree?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Mike
  • 741
  • 13
  • 40
  • if You are working with remote repository , try to enter the server where this repository is located and compare this files. try to run `git fsck` on remote server , if everything is correct there just remove your local repository and make `git clone` – Vlad Nikitin Jan 16 '14 at 12:49
  • the problem is on the remote, the errors are on the remote. – Mike Jan 16 '14 at 15:46

2 Answers2

3

First since the issue is on the server, check if you don't have any clone which would not show the same issue: you could make a local bare repo clone out of that clone, and replace your "user@server:/var/git/REPOSITORY.git" with a copy of said bare repo.

Second, on the server:
Simply make a copy of user@server:/var/git/REPOSITORY.git in user@server:/var/git/REPOSITORY2.git, remove those '_' files and see if the error persists.
My guess is: the missing commit and tree will still be there.
That means you need to look for those in a clone in order to restore them, as I recommend in "How to diagnose and fix git fatal: unable to read tree".
See more at "How to fix corrupted git repository?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Weird, the missing tree and commit just dissapeared somehow, i really dont understand that! the deletion of the sha1 files fixed it, because they werent connected to anything. Is it safe now to overwrite the new REPO_TEST.GIT with the REPO.GIT folders? just delete original and rename test to original name? all the users that are connected to it will remain connected as if it was the old one ? – Mike Jan 20 '14 at 11:48
  • @user1725378 I would recommend *moving* the old one, and *renaming* the new one, rather than overwriting. – VonC Jan 20 '14 at 11:51
0

This is my workaround for what I think is the same issue. Feedback appreciated.

Commands highlighting issue:

git fsck --full --no-dangling
bad sha1 file: ./objects/e2/6eb31e9013bda60158eb9d63d4500e005b2911 (2016-04-18 09-12-50)

ls -alh objects/e2/6eb31e9013bda60168eb9d63d4600e006b2911*
-rwxrwxrwx 1 Unknown+User Unknown+Group 1.1K Sep  7 18:33  objects/e2/6eb31e9013bda60168eb9d63d4600e006b2911
-rwxrwxrwx 1 Unknown+User Unknown+Group 1.1K Sep  7 18:33 'objects/e2/6eb31e9013bda60168eb9d63d4600e006b2911 (2016-04-18 09-12-50)'

My Workaround:

# Create New Repository
cd /tmp
git init --bare --shared repo_new

# Export commits from repo_old and import into the repo_new
#
# https://git-scm.com/docs/git-fast-export
# git fast-export --all | (cd /empty/repository && git fast-import)

cd repo_old
git fast-export --all | (cd /tmp/repo_new && git fast-import)

Note*: After this step, I just deleted the old cloned instances and cloned this new git repository.

Mark
  • 66
  • 1
  • 5