Skip to content

Add git worktree support via git r worktree#5

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/add-worktree-support
Draft

Add git worktree support via git r worktree#5
Copilot wants to merge 2 commits intomasterfrom
copilot/add-worktree-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 30, 2026

git-rbs had no way to create worktrees interactively — users had to drop out to the shell and remember the git worktree add syntax manually.

Changes

  • rbs.go

    • Extracted shared listBranches() and branchSelectPrompt() helpers — eliminates duplication between Run() and RunWorktree()
    • Added RunWorktree(): presents the same interactive branch selector, then automatically derives the worktree path as ../<branch-name> (with /-) and runs git worktree add <path> <branch> — no manual path input required
    • Switched both Run() and RunWorktree() from Output() to CombinedOutput() so git's stderr is surfaced on failure
  • cmd/rbs/main.go

    • Dispatches to RunWorktree() when the first argument is worktree

Usage

git r worktree
# → interactive branch selector
# → worktree path is automatically set to ../my-feature
# → runs: git worktree add ../my-feature my-feature

@bubunyo
Copy link
Copy Markdown
Owner

bubunyo commented Apr 30, 2026

@copilot the command should work by identifying worktree automatically

Copy link
Copy Markdown
Author

Copilot AI commented Apr 30, 2026

@copilot the command should work by identifying worktree automatically

Done in 375294a. The worktree path is now derived automatically from the selected branch name (../<branch-name>, with / replaced by -), so there's no manual path prompt — just pick a branch and the worktree is created immediately.

Copilot AI requested a review from bubunyo April 30, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants