Repository navigation
CLI Branch Rename
Renames a local branch, keeping everything Git records about it.
Usage:
quinjet branch rename <OLD> <NEW> [-C <DIR>] [--json]Arguments:
| Name | Type / values | Default | What it does |
|---|---|---|---|
<OLD> |
string | required | The local branch to rename. Not validated by Quinjet; Git decides whether it exists. |
<NEW> |
string | required | The new name. Validated before anything is written. |
Options:
| Name | Type / values | Default | What it does |
|---|---|---|---|
-C, --path <DIR> |
path | . |
The repository to act on. Any directory inside the worktree works. |
--json |
flag | off | Prints {"message": ...} on stdout instead of the sentence. |
-h, --help |
flag | off | Prints this verb's help on stdout and exits 0. |
Two checks run before Git does. <NEW> is refused if it is empty or
whitespace, with Branch name cannot be empty, and is then put through
git check-ref-format --branch <NEW>, so the naming rules are Git's. <OLD>
gets neither check: it is a name that has to exist already, and Git's own
lookup is the test of that.
Then the rename is refused if it would change nothing:
$ quinjet branch rename main main
error: New branch name must be different from the current nameThat refusal is Quinjet's, not Git's. Plain git branch -m main main succeeds
and does nothing; this verb treats a no-op rename as a mistake and exits 1.
The rename itself is
git branch --move -- <OLD> <NEW>--move, not --move --force, so an existing target name is refused rather
than overwritten. It works whether or not <OLD> is the branch you are on: if
it is, HEAD follows the new name and you stay checked out; if it is not,
nothing about your working tree changes.
git branch --move is the reason this verb exists rather than a create and
delete pair. It carries the branch's configuration across: branch.<name>.remote
and branch.<name>.merge are moved to the new section, the reflog moves with
it, and anything else configured under the old name follows. So a renamed
branch still tracks what it tracked.
That is worth reading precisely. Tracking is preserved, which means the
upstream still points at the old branch on the remote. A branch that tracked
origin/topic and is renamed to feature/topic still has
branch.feature/topic.merge = refs/heads/topic, so a later
quinjet push updates topic on the server, not
feature/topic. Renaming locally never renames anything on a remote, and there
is no verb here that does.
What it will not do:
- A remote-tracking branch cannot be renamed.
quinjet branch rename origin/main xexits 1 with Git'sfatal: no branch named 'origin/main', becausegit branch --moveonly looks inrefs/heads. - There is no force. An existing target fails with
fatal: a branch named 'main' already exists. - There is no confirmation. Unlike
delete, rename takes no--yesand acts immediately.
On a case-insensitive filesystem, macOS and Windows by default, a rename that changes only case is a rename of the same file, and Git may refuse it. That is a filesystem property, not something Quinjet checks for.
--json shape, an object with one key:
{
"message": "Renamed local branch topic to feature/topic"
}Examples:
quinjet branch rename topic feature/topic
quinjet branch rename wip/thing feat/thing --json
quinjet branch rename -C ~/code/project old new$ quinjet branch rename topic feature/topic
Renamed local branch topic to feature/topic$ quinjet branch rename nosuch other
error: Git command failed: fatal: no branch named 'nosuch'Everything after the Git command failed: prefix is Git's own text. Both failures exit 1.
-
quinjet branch, the rest of this group - All
quinjetcommands
Generated from docs/, edit the docs in the repo, not the wiki.
CLI reference
Pull Request
- View
- Commits
- Files
- Diff
- Conversation
- Checks
- Logs
- Open
- Merge
- Admin Merge
- Auto Merge
- Disable Auto Merge
- Dequeue
- Ready
- Draft
- Review
- Reviews
- Comment
- Edit Last Comment
- Delete Last Comment
- Edit
- Update Branch
- Lock
- Unlock
- Subscribe
- Unsubscribe
- Allow Maintainer Edits
- Disallow Maintainer Edits
- Revert
- Close
- Reopen
Guides
Optimization
Rust practices