克隆现有仓库:VCS → Get from Version Control(或 VCS → Checkout from Version Control),选择 Git,填入远程仓库 URL(如 git@github.com:user/repo.git 或 https://github.com/user/repo.git),指定本地目录后 Clone。
初始化新仓库:VCS → Import into Version Control → Create Git Repository,选择项目根目录完成初始化;随后使用 Commit(提交)、Push(推送)、Pull(拉取)等完成日常协作。
四 远程仓库与认证配置(以 GitHub 为例)
SSH(推荐):在终端生成密钥(如 ssh-keygen -t rsa -b 4096 -C “email@example.com”),将公钥(默认 ~/.ssh/id_rsa.pub)添加到 GitHub → Settings → SSH and GPG keys;在 IDEA 添加远程时使用 git@github.com:user/repo.git。
HTTPS:复制仓库的 HTTPS 地址,在 IDEA 添加远程时使用 https://github.com/user/repo.git;为避免频繁输入凭据,建议配置 Git 凭证管理器 或 IDE 内置账户凭据存储。