How do I rename a local Git branch?

后端 未结 30 1584
轻奢々
轻奢々 2020-11-22 11:48

I don\'t want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.

How can I rename a local branch wh

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 12:14

    If you want to:

    • Rename the Git repository, run: git branch -m
    • Delete the old branch by: git push origin: old-name new-name
    • Commit it using: git commit
      • and then push using: git push origin new_branch_name:master
    • If you want to check the status then use: git status
    • If you want to check out then use: git checkout

提交回复
热议问题