LoginSignup
2
0

More than 3 years have passed since last update.

<Git>ブランチの作成と移動

Posted at

ブランチの作成と移動の仕方をまとめる。

まずは、ブランチを作成

$git branch ブランチ名

そして、チェックアウトをする。
Gitのチェックアウト(checkout)とは、「ブランチを切り替えたいとき」に使用するコマンド。

$git checkout ブランチ名

これで、「ブランチを作成し、移動する」ということができるようになったが、
これを一発でやってくれるのが、「-b」オプションである

$ git checkout -b ブランチ名

ここで、

$ git checkout -b 新たに作成したいブランチ名 起点となるブランチ名

のように第二引数に起点となるブランチ名を指定することで、分岐元を設定することができる。
これを指定しないと、現在いるブランチからブランチを作成し、checkoutすることになる。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0