HTTPSを使用したリポジトリのクローン方法
ヒント
HTTPSクローニングは、CursorでGitリポジトリを始めるための安全で簡単な方法です。
基本的なHTTPSクローニング
コマンドパレットの使用
- コマンドパレットを開く(Ctrl/Cmd + Shift + P)
- 「Git: Clone」と入力
- リポジトリURLを入力
- 保存先フォルダを選択
ターミナルの使用
# 基本的なクローンコマンド
git clone https://github.com/username/repository.git
# 特定のフォルダにクローン
git clone https://github.com/username/repository.git my-project
認証方法
1. 個人アクセストークン
- GitHub
- GitLab
# URLにトークンを使用
git clone https://username:[email protected]/username/repository.git
# または認証情報を設定
git config --global credential.helper store
# URLにトークンを使用
git clone https://oauth2:[email protected]/username/repository.git
# または認証情報マネージャーに保存
git config --global credential.helper cache
2. 認証情報マネージャー
# Windows
git config --global credential.helper wincred
# macOS
git config --global credential.helper osxkeychain
# Linux
git config --global credential.helper cache
高度なクローンオプション
1. 浅いクローン
# 履歴を制限してクローン
git clone --depth 1 https://github.com/username/repository.git
# 特定のブランチをクローン
git clone --branch main --depth 1 https://github.com/username/repository.git
2. スパースチェックアウト
# リポジトリを初期化
git clone --no-checkout https://github.com/username/repository.git
cd repository
# スパースチェックアウトを設定
git sparse-checkout init
git sparse-checkout set folder1 folder2
git checkout main
一般的な問題
1. 認証失敗
# 保存された認証情報を確認
git config --list | grep credential
# 保存された認証情報をクリア
git config --global --unset credential.helper
2. SSL証明書の問題
# SSLを確認
git config --global http.sslVerify true
# 検証をスキップ(推奨されません)
git config --global http.sslVerify false
3. プロキシ設定
# プロキシを設定
git config --global http.proxy http://proxy.example.com:8080
# プロキシを削除
git config --global --unset http.proxy