git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Antw: [EXT] Re: bug in "git fsck"?

From
René Scharfe <l.s.r@web.de>
Date
Jul 6, 2021, 14:25 UTC
Message-ID
<fcfd0401-df5b-15ec-29c4-74d2903274cd@web.de>
In-Reply-To
<60E40275020000A1000422F7@gwsmtp.uni-regensburg.de>
Am 06.07.21 um 09:12 schrieb Ulrich Windl:
Show 30 quoted lines
>>>> René Scharfe <l.s.r@web.de> schrieb am 05.07.2021 um 16:44 in Nachricht
> <77655a4e-8c39-5ccc-71af-d2d8684bf208@web.de>:
>> Am 05.07.21 um 09:42 schrieb Ulrich Windl:
>>>> You *can* overwrite them using "git branch --force foo" and then
>>>> "git branch -d foo" works.
>>>
>>> Would it be OK to force the branch to any commit (e.g.: "master"), relying
>
>> on
>>> the fact that any reference (read: "master") to that commit will prevent
>> actual
>>> removal of the commit?
>>
>> Yes, any valid commit would do.  This turns dangling branches into
>> normal delete-able ones.  Other branches are unaffected.
>
> OK, but either it does not work, or I did not understand what to do:
>
>> git branch --force bitmap-generic
> fatal: Not a valid object name: 'bitmap-generic'.
>> git fsck
> Checking object directories: 100% (256/256), done.
> Checking objects: 100% (173/173), done.
> notice: HEAD points to an unborn branch (bitmap-generic)
> dangling blob 0458be7cf03f35be365c819afe0104ff3c178ca0
> dangling blob 3000d29f0a652f3f7ed25572cac9969b90adeca5
> dangling commit 90e8531086d3efaeefdf6c8d39b6782e49dd2a0d
> dangling commit b598195f859106662bde746f391a7df9162231e9
> dangling tree fb4866ab5cc2f0c34a63334b90550ef7199a2098
> ...
First: Please make backups.
Here's what works for me.  First reproducing the error:
   $ echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >.git/refs/heads/broken
   $ git branch --delete --force broken
   error: Couldn't look up commit object for 'refs/heads/broken'

Now I have a broken branch that I cannot delete. We should be on the same page now.

   $ git branch
     broken
   * master
So I'm on master, a valid branch.
   $ git branch --force broken

Now the broken branch is overwritten and points to the same commit as master.

   $ git branch --delete broken
   Deleted branch broken (was 83d267b).
And now it's gone.
René
Previous: Ulrich WindlNext: Ulrich Windl
Message 7 of 13 in “bug in "git fsck"?”
  1. Ulrich WindlJul 2, 2021
  2. Junio C HamanoJul 2, 2021
  3. René ScharfeJul 3, 2021
  4. Antw: [EXT] Re: bug in "git fsck"?Ulrich Windl, Jul 5, 2021
  5. René ScharfeJul 5, 2021
  6. Ulrich WindlJul 6, 2021
  7. René ScharfeJul 6, 2021
  8. Ulrich WindlJul 8, 2021
  9. René ScharfeJul 8, 2021
  10. Junio C HamanoJul 5, 2021
  11. Antw: [EXT] Re: bug in "git fsck"?Ulrich Windl, Jul 5, 2021
  12. Ævar Arnfjörð BjarmasonJul 5, 2021
  13. Antw: [EXT] Re: bug in "git fsck"?Ulrich Windl, Jul 5, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.