feat: add mv/rename command for worktree renaming#95
Merged
helizaga merged 5 commits intocoderabbitai:mainfrom Feb 2, 2026
Merged
feat: add mv/rename command for worktree renaming#95helizaga merged 5 commits intocoderabbitai:mainfrom
helizaga merged 5 commits intocoderabbitai:mainfrom
Conversation
Add `git gtr mv` (alias: `git gtr rename`) command to rename both the worktree directory and its associated branch in a single operation. Features: - Renames branch with `git branch -m` - Moves worktree directory with `git worktree move` - Rollback on failure (restores branch name if move fails) - Warns about remaining remote branches - Supports --force flag for locked worktrees Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add documentation for the new `git gtr mv` command in the Commands section of README.md. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The codebase uses `git worktree remove` and `git worktree move` which were introduced in Git 2.17 (April 2018). The previous documentation incorrectly stated Git 2.5+ as the minimum requirement. Updated: - README.md badge and requirements section - CLAUDE.md version compatibility section - docs/troubleshooting.md version support table Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughAdded a new Changes
Sequence DiagramsequenceDiagram
actor User
participant CLI as git gtr
participant Branch as git branch
participant Worktree as git worktree
User->>CLI: git gtr mv old-name new-name [--force] [--yes]
CLI->>CLI: validate inputs & resolve worktree
CLI->>CLI: check conflicts (paths & branches)
CLI->>Branch: git branch -m old-name new-name
activate Branch
Branch-->>CLI: success
deactivate Branch
CLI->>Worktree: git worktree move [--force] old-path new-path
activate Worktree
alt move succeeds
Worktree-->>CLI: success
CLI-->>User: renamed successfully
else move fails
Worktree-->>CLI: error
CLI->>Branch: git branch -m new-name old-name (rollback)
activate Branch
Branch-->>CLI: rollback complete
deactivate Branch
CLI-->>User: error + rollback notice
end
deactivate Worktree
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Remove -f short flag (inconsistent with other commands) - Add --yes flag and confirmation prompt before rename - Use git -C "$repo_root" for all git commands (safe when cwd != repo root) - Replace unquoted $force_flag with proper array pattern - Remove dead "." / ".." validation (sanitize_branch_name prevents these) - Update help text, README, completions, and CLAUDE.md test steps
helizaga
pushed a commit
that referenced
this pull request
Feb 11, 2026
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.
Pull Request
Description
Add
git gtr mv(alias:git gtr rename) command to rename both the worktree directory and its associated branch in a single operation.Features:
git branch -mgit worktree move--forceflag for locked worktreesMotivation
Fixes #93
Type of Change
Testing
Manual Testing Checklist
Tested on:
Core functionality tested:
git gtr new <branch>- Create worktreegit gtr go <branch>- Navigate to worktreegit gtr editor <branch>- Open in editor (if applicable)git gtr ai <branch>- Start AI tool (if applicable)git gtr rm <branch>- Remove worktreegit gtr list- List worktreesgit gtr config- Configuration commands (if applicable)git gtr mv,git gtr renameTest Steps
git gtr new test-old-namegit gtr mv test-old-name test-new-namegit branch | grep test-new-namegit gtr listgit gtr mv 1 new-name(should reject)git gtr rename test-new-name another-namegit gtr rm another-nameExpected behavior: Worktree directory and branch both renamed
Actual behavior: Works as expected
Breaking Changes
Note: This PR also updates the documented minimum Git version from 2.5+ to 2.17+. This is not a new requirement - the existing
git gtr rmcommand already usesgit worktree removewhich requires Git 2.17+.Checklist
Before submitting this PR, please check:
git gtr(production) and./bin/gtr(development)Additional Context
Test environment: macOS, Git 2.52.0, Bash 5.3.9
License Acknowledgment
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.
Summary by CodeRabbit
New Features
git gtr mv(aliasrename) to rename a worktree and its local branch, with optional--force/--yesflags.Documentation
mv/rename.Chores
mv/rename.Tests