fix: update worktree .git pointers after context remove repo restore#50
Merged
guodong-sq merged 1 commit intomainfrom Mar 22, 2026
Merged
Conversation
6aa6c1f to
9357a15
Compare
When wt context remove reverses the repo migration (moves the main repo back to the symlink location), all existing worktrees' .git files still contain gitdir: pointers to the old .git path, breaking git operations in those worktrees. After the move, iterate .git/worktrees/*/ and update each worktree's .git file to point to the new .git location. Applies to both CLI (bin/wt-context) and plugin (DeleteContextAction). Also extracts repo restore logic from DeleteContextAction into ContextService.removeContext() for clean separation of concerns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9357a15 to
d12ba0a
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug in
wt context remove(PR #49) where reversing the repo migration breaks all existing worktrees.When
wt context removemoves the main repo back from~/.wt/repos/<name>/baseto the original location (e.g.,~/Dev/myrepo), worktrees'.gitfiles still containgitdir:pointers to the old.gitpath. This breaks all git operations in those worktrees.Fix: After moving the repo, iterate
.git/worktrees/*/, read eachgitdirfile to find the worktree's.gitfile, and rewrite the pointer to the new location.Applies to both CLI (
bin/wt-context) and plugin (DeleteContextAction.kt).Test plan
cd test && bats unit/ integration/cd wt-jetbrains-plugin && ./gradlew test.gitpointers updated after repo move,git statusworks🤖 Generated with Claude Code