Fix missing commit

倾然丶 夕夏残阳落幕 提交于 2019-12-11 03:34: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:


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
    


来源:https://stackoverflow.com/questions/16745105/fix-missing-commit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!