用 git clone 下载 GitHub 仓库
把任意 Git 仓库完整下载到电脑上的一个新文件夹里。
运行:git clone https://github.com/user/repo.git,会生成一个包含完整项目历史的 repo 文件夹。
01命令
命令
$ git clone https://github.com/user/repo.git02作用说明
git clone 会把整个仓库——所有文件加上完整提交历史——下载到一个以仓库名命名的新文件夹。网址可以在 GitHub 页面绿色的 Code 按钮里复制。想放到指定文件夹,在命令末尾加上文件夹名即可:git clone https://github.com/user/repo.git my-folder
03风险
!注意: 私有仓库需要登录验证;登录失败时,先到 GitHub 设置里创建个人访问令牌(Git for Windows 会把它存在 Windows 凭据管理器里)。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- git-clone Documentation依据: Official Git documentation: git clone clones a repository into a new directory, with the repository URL as the main argument.
- Cloning a repository依据: GitHub's guide shows cloning a repository with git clone https://github.com/OWNER/REPO.git on the command line.
最后验证: 2026-09-19 · 分类: 开发者