Skip to content

Instantly share code, notes, and snippets.

@andkirby
Created December 22, 2025 15:06
Show Gist options
  • Select an option

  • Save andkirby/c579ef6dccf9c1615f6daab2e9e3c3d3 to your computer and use it in GitHub Desktop.

Select an option

Save andkirby/c579ef6dccf9c1615f6daab2e9e3c3d3 to your computer and use it in GitHub Desktop.

IDE Integration

JetBrains IDEA

The post-checkout hook automatically creates .idea/scopes/ticket___code.xml with ticket-specific patterns:

<component name="DependencyValidationManager">
  <scope name="ticket &amp; code"
         pattern="(!file:*//*&amp;&amp;!file:*||
                   file:docs//*&amp;&amp;(!file:docs/CRs//*||
                                     file:docs/CRs/*101*||
                                     file:docs/CRs/*101//*)||
                   file:tests//*||
                   file:src//*||
                   file:shared//*||
                   file:server//*||
                   file:mcp-server//*||
                   file:playwright*||
                   file:package*||
                   file:README*||
                   file:prompts//*)&amp;&amp;!file:**/dist//*" />
</component>

This scope filters files to show:

  • All docs/CRs/*101* files (ticket-specific)
  • Core code directories: tests/, src/, shared/, server/, mcp-server/
  • Build and package files
  • Excludes dist/ directories

Using Scopes in IntelliJ

  1. Open the worktree in IntelliJ IDEA
  2. Go to File → Settings → Editor → Inspections → Scope
  3. Select the "ticket & code" scope
  4. Use it for:
    • Running inspections on ticket-specific code
    • Code analysis limited to ticket scope
    • Find references within ticket context

VS Code

For VS Code users, you can add this to .vscode/settings.json:

{
  "files.exclude": {
    "**/node_modules": true,
    "**/dist": true,
    "**/.git": true
  },
  "search.exclude": {
    "**/node_modules": true,
    "**/dist": true
  }
}

Troubleshooting

Common Issues

  1. "parse error near '}'"

    • Ensure you're using bash/zsh, not plain sh
    • Check for unescaped quotes in the alias
  2. Worktree path not expanding ~

    • Use $HOME instead of ~ in config
    • Or ensure the script includes ~ expansion
  3. Post-checkout hook not running

    • Check hook is executable: chmod +x .git/hooks/post-checkout
    • Verify you're in a worktree: git rev-parse --git-dir should show .git/worktrees/...
  4. IDEA scope not created

    • Check hook output: Should show "Created IDEA scope file..."
    • Verify .idea/scopes/ directory exists
    • Check branch name contains 3 digits

Debug Mode

Add debug output to the script:

# Add at the beginning of the function
set -x  # Enable debug mode

Or create a debug version:

git config --global alias.wt-debug '!f() {
    set -x
    # ... rest of script ...
}; f'

Resetting Configuration

# Remove all worktree configurations
git config --global --unset worktree.defaultPath
git config --unset worktree.defaultPath

# Reset git alias
git config --global --unset alias.wt

# Remove post-checkout hook
rm .git/hooks/post-checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment