$ git branch
$ git branch -a
リモートリポジトリにあるブランチを含む全てのブランチの一覧を表示する。
$ git branch <branchname>
<branchname>
ブランチを作成する。ブランチの切り替えは行わない。
$ git checkout
「ブランチの切り替え作業」と「作業ツリーのファイルの復元」の2つの役割がある
$ git checkout <branchname>
<branchname>
ブランチへ切り替え
$ git checkout -b <branchname>
<branchname>
ブランチを作成し、同時に切り替えも行う
$ git checkout -f <branchname>
ファイルや作業ツリーの変更内容を破棄して、強制的に<branchname>
ブランチに切り替える
$ git checkout <filename>
ローカルの<filename>
の変更内容を取り消す
$ git checkout .
ローカルのすべての変更を取り消す(新規作成されたファイルは残る)
Gitの新コマンド "switch","restore"
Git 2.23から新コマンドswitch
,restore
が追加された
$ git switch
$ git switch -c <branchname>
git checkout -b <branchname>
と同義
-cはcreateの略
$ git switch <branchname>
git checkout <branchname>
と同義
$ git restore
$ git restore .
git checkout .
と同義
$ git restore <filename>
git checkout <filename>
と同義