🆚
git checkout と switch/restore の対応表
git checkout
の後継として追加された git switch
/ git restore
を使っていきましょう!
n番煎じ。
対応表
checkout | switch/restore | 説明 |
---|---|---|
git checkout <branch> |
git switch <branch> |
ブランチを切替 |
git checkout -b <branch> |
git switch -c <branch> |
新しいブランチを作成して切替 |
git checkout <commit> |
git switch --detach <commit> |
特定コミットに切替 |
git checkout <file> |
git restore <file> |
ファイルの変更を破棄 |
git checkout <commit> <file> |
git restore -s <commit> <file> |
特定コミットのファイルを復元 |
補足
-
-c
は--create
の略 -
-s <commit>
は--source=<commit>
の略
Discussion