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

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

From
Josh Soref <jsoref@gmail.com>
Date
Jul 12, 2023, 00:45 UTC
Message-ID
<CACZqfqAB7zyn56+NOL=E8Y3bXNiQnJdmVXgzsnj78C-Anw-h2Q@mail.gmail.com>

Consider this series of unfortunate commands: ```sh % (cd $(mktemp -d); git init; (touch a; git add a; git commit -m a; touch b; git add b; git commit -m b; git bisect start; git branch next HEAD~; git checkout next ) 2>/dev/null >/dev/null; git log --oneline -1 HEAD; git branch -f main HEAD;) Initialized empty Git repository in /private/var/folders/r3/n29fz25x72x191fdv6mhhr3m0000gp/T/tmp.fGD64HAf/.git/ accc238 (HEAD -> next) a 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.

Next: Junio C Hamano
Message 1 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.