git-rename-branch
Rename a Git branch
TLDR
Rename the branch you are currently on
Rename a specific branch
SYNOPSIS
git-rename-branch [<remote>] <old-branch> <new-branch>
PARAMETERS
<old-branch>
Current branch name to rename
<new-branch>
New branch name
[<remote>]
Remote name (default: origin)
--local-only
Rename only locally, skip remote (common in scripts)
--force
Force overwrite if new branch exists (like -M)
DESCRIPTION
The git-rename-branch is not a core Git command or standard Linux utility. It often refers to custom scripts, aliases, or third-party tools designed to simplify renaming Git branches locally and pushing changes to remotes.
Standard Git uses git branch -m <old> <new> for local renames. For remotes, delete the old branch (git push origin --delete old) and push the new one (git push origin -u new). Custom git-rename-branch scripts typically automate this, handling local rename, remote delete, and new branch push in one step.
Common implementations (e.g., GitHub Gists or npm packages) accept old/new branch names and an optional remote (default: origin). Always verify the script source for safety.
CAVEATS
Not built-in; verify custom scripts to avoid security risks.
Current branch rename omits <old-branch>.
Remote operations need push permissions.
Does not handle protected branches.
EQUIVALENT CORE COMMAND
Use git branch -m old new locally; git push origin -d old; git push origin -u new for remotes.
CURRENT BRANCH
git branch -m new renames checked-out branch without specifying old name.
HISTORY
Core Git branch renaming via git branch -m since Git 1.0 (2005). Custom git-rename-branch scripts popularized ~2010 on GitHub for workflow convenience, evolving with Git's remote features.
SEE ALSO
git-branch(1), git-push(1), git-remote(1)


