質問

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?

役に立ちましたか?

解決

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?".

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top