How do I rename a local Git branch?

后端 未结 30 1588
轻奢々
轻奢々 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:23

    Actually you have three steps because the local branch has a duplicate on the server so we have one step for local on two steps on the server:

    1. Rename local: just use the following command to rename your current branch, even you checked it out:
      git branch -m  
      
    2. Delete the server one: use the following command to delete the old name branch on the server:
      git push  :
      
    3. Push the new one: now it's time to push the new branch named on the server:
      git push -u 
      

提交回复
热议问题