管理人Kのひとりごと

デジモノレビューやプログラミングや写真など

ブランチを作ってそのまま移動する(git)

①ブランチを作る→②①で作ったブランチに移動する、ではなく、ブランチを作ってそのまま移動する、をしばしばやりたくなるんだけれど忘れがちなのでメモ。

実行方法

$ git checkout -b <新たに作るブランチ名>

実行例

pi@raspi:~/scripts/test_script $ git branch
* master
pi@raspi:~/scripts/test_script $ git checkout -b test_branch
Switched to a new branch 'test_branch'
pi@raspi:~/scripts/test_script $ git branch
  master
* test_branch