--- tags: Git, disqus: hackmd --- # Git查看分支、建立分支、分支重新命名、刪除分支 ## 查看分支 這個指令會show出你目前所有的分支名稱 ``` $ git branch ``` ## 建立分支 ``` $ git branch <branchname> ``` 但是通常都是使用 ``` $ git checkout -b <branchname> ``` 這個的意思是,建立並且切換至該分支 ## 分支重新命名 如果要在指向任何分支時重命名分支 ``` $ git branch -m <oldname> <newname> ``` 如果你想要想要更改目前分支的名稱 ``` $ git branch -m <newname> ``` ## 刪除分支 ``` $ git branch -d <branch> ``` #### 參考文章 [How do I rename a local Git branch?](https://stackoverflow.com/questions/6591213/how-do-i-rename-a-local-git-branch) [連猴子都能懂的Git入門指南](https://backlog.com/git-tutorial/tw/stepup/stepup2_4.html)