git のブランチ名を変更する
git
Published: 2019-10-10

やったこと

ブランチ名を変更します

確認環境

$ git --version
git version 2.17.2 (Apple Git-113)

調査

パターン1 (oldbranch は省略)

変更前

$ git branch
  master
* test1
$ git branch -m test2
$ git branch
  master
* test2

test2 に変わりました。

パターン2 (oldbranch を指定)

変更前

$ git branch
* master
  test2
$ git branch -m test2 test1
$ git branch
* master
  test1

test2 -> test1 に変わりました。

ヘルプ抜粋

$ git branch --help
 git branch (-m | -M) [<oldbranch>] <newbranch>