fatal: bad object xxx

前端 未结 12 2220
[愿得一人]
[愿得一人] 2021-02-03 17:00

I tried reverting to a previous git commit with:

git revert xxx

I\'m now receiving this error as a response:

fatal: bad object          


        
12条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-03 17:40

    [Edit 1, 19 Nov 2016] While this would sometimes indicate repository corruption, it turns out to occur on Windows when some command—usually, another Git in another task—is holding internal files open and locked. In this case, terminating the other task should fix it. Original answer is below.

    [Edit 2, 6 May 2020] Suppose xxx above resembles, e.g., b34789c0b0d3b137f0bb516b417bd8d75e0cb305 (a raw hash ID). If you got this from cut-and-paste, be sure that it's for this repository (it's easy to grab a hash ID from some other repository without realizing it, especially if you have multiple windows open). If you retyped it yourself, be sure there aren't any typos. If this involves submodules, make sure the submodule is up to date. See the comments on the question and some of the answers, including this one.


    bad object with some hexadecimal number tends to mean that a tag has an invalid reference number in it, but can also occur for a few other strange cases. For instance, if I do a:

    $ git tag foo
    $ vi .git/refs/tags/foo
    

    and change the last character (in this case from 6 to 5) and write that out:

    $ git log foo
    fatal: bad object foo
    

    What exactly is the xxx here and where did it come from?

提交回复
热议问题