基本コマンド

git branch                    # ブランチ一覧
git switch -c ブランチ名       # 作成して切り替え
git switch ブランチ名          # 切り替え
git merge ブランチ名           # マージ
git branch -d ブランチ名       # 削除

よくある使い方

git switch -c feature/new-function
git add .
git commit -m "add new function"
git switch main
git merge feature/new-function
git branch -d feature/new-function

ハマったポイント

  • 古いGitでは git checkout。新しいGitでは git switch が推奨
  • マージ前に必ずmainに切り替える

関連記事