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

"git branch -f" corrupt other worktree

From
FKfrank kulow <kulow.f@googlemail.com>
Date
May 2, 2019, 11:58 UTC
Message-ID
<CAA2qrhBmbSe5R0xQPBZiRcz0MGG=JcF4BjxHqmyeTFNR19FKbg@mail.gmail.com>
git version 2.21.0.windows.1
> /c/tmp/gt (Branch_702091a0)

$ git worktree add ../wt master Preparing worktree (checking out 'master') HEAD is now at f534c32 4

> /c/tmp/gt (Branch_702091a0)

$ git branch -D master error: Cannot delete branch 'master' checked out at 'C:/tmp/wt'

#but this is possible:
> /c/tmp/gt (Branch_702091a0)
$ git branch -f master HEAD
#and the other worktree is now corrupted:
> /c/tmp/wt (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
        modified:   txt.txt
        deleted:    txtb.txt
greetings f.kulow
Next: Duy Nguyen
Message 1 of 6 in “"git branch -f" corrupt other worktree”
  1. frank kulowMay 2, 2019
  2. Duy NguyenMay 2, 2019
  3. Ævar Arnfjörð BjarmasonMay 2, 2019
  4. Duy NguyenMay 2, 2019
  5. Duy NguyenMay 2, 2019
  6. Duy NguyenMay 2, 2019

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.