Git ・Github の安全なコードを管理・ローカルで作業

GitHubからプロジェクトを取得(クローン)

方法①: HTTPS を使う

git clone https://github.com/ユーザー名/リポジトリ名.git

方法②: SSH を使う(SSH 設定済みの場合)

git clone git@github.com:ユーザー名/リポジトリ名.git

クローン後は、作業フォルダへ移動

cd sample-project
git branch

📌 1. ブランチを作成する

✅ 方法①: ターミナルで作成

git checkout -b feature-branch
または
git switch -c feature-branch
git branch

✅ 方法②: VS Code の GUI で作成

VS Code の左下にあるブランチ名をクリック → 「+ Create New Branch」を選択

📌 2. コードを編集し、コミットする

✅ ファイルを変更して保存

git add .
git commit -m "新しい機能を追加"

📌 3. GitHub にプッシュ

git push origin feature-branch

📌 4. Pull Request(PR)を作成

✅ GitHub で「Pull requests」タブをクリック → 「New pull request」ボタンをクリック

feature-branch → main を選択
「Create pull request」

📌 5. 作業終了後、ブランチを削除

git branch -d feature-branch