rename-branch
Renames a specified branch to a new name across repositories.
Usage
git-wrangler rename-branch [--repo <path>] --oldbranch <old_name> --newbranch <new_name> [--guided]
What it does
Discovers Git worktrees under the current directory, or targets exactly one worktree with --repo, and renames a local branch with git branch -m <old> <new>. Repositories where the old branch does not exist or the new branch name is already taken are skipped.
Options
| Flag | Required | Description |
|---|---|---|
--repo <path> | Optional | Target exactly one repository instead of discovering recursively. |
--oldbranch <name> | Required | Existing local branch name. Interactive runs prompt when omitted. |
--newbranch <name> | Required | New local branch name. Interactive runs prompt when omitted. |
--guided | Optional | Interactively configure command options before execution. |
Example
# Rename 'master' to 'main' across all repos
git-wrangler rename-branch --oldbranch master --newbranch main
Notes
- Repositories where the old branch doesn’t exist are skipped with a yellow warning
- Repositories where the new branch name already exists are also skipped
- This only renames the local branch. It does not create, delete, or rename remote branches.
- There is no
--yes; missing branch names can be entered at prompts in interactive runs.