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

Re: [rebase] `fatal: cannot force update the branch ... checkout out at ...` is confusing when it isn't active

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2023, 20:49 UTC
Message-ID
<xmqq5y6osvmc.fsf@gitster.g>
In-Reply-To
<CACZqfqDE-SCOqVX9a8KCLAn1zSVbYxuCeU8Y=3-nhj5wbL=AWQ@mail.gmail.com>
Josh Soref <jsoref@gmail.com> writes:
Show 17 quoted lines
> Josh Soref writes:
>> fatal: cannot force update the branch 'main' checked out at
>> '/private/var/folders/r3/n29fz25x72x191fdv6mhhr3m0000gp/T/tmp.fGD64HAf'
>
>> It's true git in the repository does have a pin of sorts for the
>> `main` branch and that `git-rebase` would be very upset if the
>> branch's location were changed, but as an end user, the `main` branch
>> is not checked out, the `next` branch is checked out.
>
> Junio C Hamano wrote:
>> Fair enough.  Perhaps "cannot force update the branch 'main' in use"
>> would alleviate the confusion?
>
> That would be better.
>
> Even better would be to tell me what's using it (rebase). I'm not sure
> how possible that is.

When branch.c:prepare_checked_out() notices which branch is in use in what way in which worktree, it does check many conditions (e.g. "in this worktree, is a rebase in progress and if so which branch is being affected?") but the information is lost there to only record a mapping from branch names to worktree location. So "it is in use over there" with exact location is given, but "how it is used" is not recorded.

It shouldn't be a rocket surgery to teach the function to leave that information, but I am not offhand sure how valuable it would be to do so. After all, once you learn which worktree of yours is using the branch you wanted to touch, you'll either know already or it would be easy for you to find out what you have been doing in that other worktree anyway, no?

Previous: Josh SorefNext: Junio C Hamano
Message 4 of 6 in “[rebase] `fatal: cannot force update the branch ... checkout out at ...` is confusing when it isn't active”
  1. Josh SorefJul 12, 2023
  2. Junio C HamanoJul 12, 2023
  3. Josh SorefJul 12, 2023
  4. Junio C HamanoJul 12, 2023
  5. Re* [rebase] `fatal: cannot force update the branch ... checkout out at ...` is confusing when it isn't activeJunio C Hamano, Jul 12, 2023
  6. branch: update the message to refuse touching a branch in-useJunio C Hamano, Jul 21, 2023

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.