Skip to main content

Not in a Git Repository

Error: “Not in a git repository”
This error occurs when you run gwt commands outside of a git repository. Solution:
  1. Navigate to a directory inside a git repository:
  2. Verify you’re in a git repository:
  3. If the directory isn’t a git repository, initialize one:

Directory Already Exists

Error: “Directory already exists: /path/to/worktree”
This happens when trying to create a worktree with a name that already exists in the parent directory. Solution:
  1. Choose a different worktree name:
  2. Or remove the existing directory first:
  3. Check existing worktrees:

Merge Conflicts

Error: “Merge failed. Resolve conflicts manually.”
This occurs when using gwt merge and there are conflicts between branches. Solution:
  1. The merge command will fail and leave you in the main branch with conflicts:
  2. Resolve conflicts manually in your editor
  3. Stage the resolved files:
  4. Complete the merge:
  5. Manually remove the worktree:

Uncommitted Changes

When creating a new worktree, GWTree detects uncommitted changes and prompts you to handle them.
Options:
  1. Stash changes (recommended):
    • Select “Stash changes” when prompted
    • Your changes are saved and can be recovered with git stash pop
  2. Ignore and continue:
    • Select “Ignore and continue”
    • Changes remain in the current worktree
  3. Cancel:
    • Select “Cancel” to abort worktree creation

Pull/Rebase Failures

Error: “Pull failed” during worktree creation
This can happen when pulling latest changes from remote fails. Common causes:
  1. No network connection: Ensure you’re connected to the internet
  2. Diverged branches: Local and remote have different histories
  3. No remote configured: Repository doesn’t have a remote origin
Solution:

Worktree Already Registered

Error: “worktree registered but missing”
This happens when git has a worktree registered but the directory was manually deleted. Solution:
  1. Prune stale worktree references:
  2. Try creating the worktree again:

Editor Not Opening

Worktree created successfully but editor didn’t open
Possible causes:
  1. Editor not installed: Ensure VS Code or Cursor is installed
  2. Command not in PATH: The editor command isn’t available
  3. Wrong configuration: Editor setting in config doesn’t match your setup
Solution:
  1. Check your editor configuration:
  2. Update editor setting to one of: code, cursor, default, or none
  3. Verify the editor command works:
  4. Skip editor opening with -x flag:

Dependency Installation Failed

Error: “failed to install” after creating worktree
This happens when automatic dependency installation fails. Solution:
  1. Navigate to the worktree:
  2. Manually install dependencies:
  3. Or disable automatic installation:

Branch Name Conflicts

GWTree automatically handles branch name conflicts by appending -1, -2, etc.
If you want separate worktree and branch names:
  1. Press ESC when prompted for “Worktree & branch name:”
  2. Enter different names for worktree and branch

Cannot Merge with Uncommitted Changes

Error: “Worktree has uncommitted changes. Commit or stash them first.”
The gwt merge command requires a clean working directory. Solution:
  1. Navigate to the worktree:
  2. Commit your changes:
  3. Or stash them:
  4. Try merging again:

Node Version Issues

Error: Node version compatibility issues
GWTree requires Node.js 18.0.0 or higher. Solution:
  1. Check your Node version:
  2. Upgrade Node.js:

Getting Help

If you encounter issues not covered here:
  1. Check existing issues: github.com/ahmadawais/gwtree/issues
  2. Create a new issue with:
    • Error message
    • Steps to reproduce
    • gwt --version output
    • Operating system