Fix missing commit

2019-07-21 06:26发布

I'm new to Git. We're using Bonobo Git Server as the back-end and TortoiseGit for the client. When I do a pull I get the following in TortoiseGit -

POST git-upload-pack (328 bytes)
fatal: protocol error: bad line length character: <!DO
fatal: write error: Invalid argument


git did not exit cleanly (exit code 1)

Bonobo's error log says -

   GitSharp.Core.Exceptions.MissingObjectException: Missing commit commit 903228ffc07ea920fd944c6fcdd5d8d5ef852ff1 0 ------

I've found the missing 903228ffc07ea920fd944c6fcdd5d8d5ef852ff1 file on one of the developer's machines under .git\objects folder. How do I put this on the server and get the repo working again? Please help.

I read on a different thread that I need to repack it and push it to the server? How do I do that? I'm a newbie at Git. I'm using Windows.

1条回答
ゆ 、 Hurt°
2楼-- · 2019-07-21 06:50

First backup the corrupted repository in case you make things worse.

Then just copy the good file to git/objects/90/3228... on the server.

See Recovering from repository corruption for more information.

If there are lots of missing objects you can indeed send them in a pack:

  1. On the server, find the SHA-1 sums of the missing objects

    git fsck | grep missing | grep -o '[0-9a-f]\{40\}' > missing
    
  2. On the developer's machine, pack the missing objects

    git pack-objects --stdout < missing > objects.pack
    
  3. On the server, unpack the pack file

    git unpack-objects < objects.pack
    
查看更多
登录 后发表回答