Skip to content

Better git worktree support #33

@rekmarks

Description

@rekmarks

git worktree support appears limited at the moment, but this feature is core to my workflow (stacking or otherwise). Situation:

  • I have main as default and trunk, not checked out
  • feature-a checkout out in main repo
  • feature-b checked out in worktree

Running gh stack cascade in feature-a:

> gh stack cascade
Cascading feature-a onto main (using fork point)...
Done in 6s 453ms
Successfully rebased and updated refs/heads/feature-a.
Cascading feature-a... ok
Cascading feature-b onto feature-a (using fork point)...
Error: git checkout: fatal: 'feature-b' is already used by worktree at '~/worktrees/feature-b'

Running gh stack cascade in the feature-b worktree works, but there's a warning:

> gh stack cascade
Warning: could not save undo state: mkdir ~/worktrees/feature-b/.git: not a directory
Cascading feature-b onto feature-a (using fork point)...
Done in 6s 387ms

Being a worktree, feature-b/.git is a text file with the content:

gitdir: <path to feature-a>

It seems like the correct way to handle this would be one of:

  • cd into worktree dirs in a subshell and run commands there (ideal)
  • stop cascading when encountering a branch in a worktree (less ideal, essentially the status quo but without an error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions