Linux command
git-rename-branch 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Rename current branch
git rename-branch [new_name]
Rename specific branch
git rename-branch [old_name] [new_name]
说明
git rename-branch renames a branch both locally and on the remote. Part of git-extras, it handles the local rename, pushes the new branch name to the remote, deletes the old remote branch, and updates the upstream tracking reference in a single command. Without this tool, renaming a remote branch requires multiple steps: `git branch -m`, `git push origin new_name`, `git push origin --delete old_name`, and `git branch -u origin/new_name`.
参数
- old_name
- The current name of the branch to rename. If omitted, the current branch is used.
- new_name
- The new name for the branch.
FAQ
What is the git-rename-branch command used for?
git rename-branch renames a branch both locally and on the remote. Part of git-extras, it handles the local rename, pushes the new branch name to the remote, deletes the old remote branch, and updates the upstream tracking reference in a single command. Without this tool, renaming a remote branch requires multiple steps: `git branch -m`, `git push origin new_name`, `git push origin --delete old_name`, and `git branch -u origin/new_name`.
How do I run a basic git-rename-branch example?
Run `git rename-branch [new_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does old_name do in git-rename-branch?
The current name of the branch to rename. If omitted, the current branch is used.