By default git history also rewrites every local branch descending from the commit it changes. If another worktree has such a branch checked out, the branch moves but that worktree's index and working tree stay behind, so it shows staged changes nobody made. This matches Toon Claes's earlier report in thread 66031, where git history fixup left a second worktree dirty. Claes said GitLab has nobody planned to work on it and welcomed Gupta to pick it up.
The patch follows what git branch -f and git rebase --update-refs already do. Before replaying anything it looks for local branches containing the commit that a worktree uses, and refuses to continue if there is one. That also covers a current-worktree rebase, where git rebase --continue would later fail because the branch moved.
Junio Hamano said the intent is good but described a hole. In a bare repository whose HEAD records refs/heads/main, a worktree ../wt can check out main. Running git history there skips main as if the current worktree had it checked out, so the branch moves and ../wt shows the dropped commit's changes as staged. Gupta reproduced this.
Phillip Wood called it a useful improvement and suggested wording fixes. He noted that updating clean worktrees would be an alternative to refusing, though failing is simpler. He also observed that branch_checked_out() stores only one worktree per ref, so with multiple checkouts it may record the current worktree and miss another. He said that need not be solved here.
Gupta said v2 will ask each worktree whether it uses the current branch, covering bare repositories and branches checked out twice with git worktree add --force, and will add tests for both. A branch under rebase is refused because HEAD is detached, and the commit message will say so. Gupta also said fixup, reword, split, squash and drop all call setup_revwalk() before doing anything else, so the check covers each of them.