Git:warning: Clone succeeded, but checkout failed.

Git Clone: Checkout Failed Warning

This warning means the repository was downloaded successfully , but Git couldn't check out (write) all the files to your working directory. The .git folder and history are intact --- only the working tree has issues.

Common causes:

  1. File path/name conflicts --- filenames with characters invalid on your OS (e.g., :, *, ?, " on Windows), or case-insensitive filesystem collisions (e.g., Readme.md vs README.md on macOS/Windows)
  2. Permissions issue --- Git can't write certain files to disk
  3. Long file paths --- common on Windows where paths are limited to 260 characters by default
  4. Symlink issues --- the repo contains symlinks your OS can't create

Step 1: Diagnose the problem

bash 复制代码
cd your-repo
git status

This shows which files failed to check out.


Step 2: Try common fixes

For Windows long path issues:

bash 复制代码
git config --global core.longpaths true
git restore --source=HEAD :/

For Windows filename/case issues:

bash 复制代码
git config --global core.protectNTFS false
git restore --source=HEAD :/

For permission issues:

Run your terminal as Administrator (Windows) or use sudo (Linux/Mac), then retry:

bash 复制代码
git restore --source=HEAD :/

For symlink issues:

bash 复制代码
git config --global core.symlinks false
git restore --source=HEAD :/

Step 3: If all else fails, clone with a sparse checkout to skip problematic files:

bash 复制代码
git clone --no-checkout <repo-url>
cd your-repo
git sparse-checkout init
git checkout

相关推荐
Gary Studio23 分钟前
Git vscode 插件推荐
ide·git·vscode
StackNoOverflow1 小时前
IDEA + Git + Gitee 全流程实战:从安装、提交到解决冲突
git·gitee·intellij-idea
淘矿人15 小时前
从0到1:用Claude启动你的第一个项目
开发语言·人工智能·git·python·github·php·pygame
lpfasd12315 小时前
Git/Gitee/GitHub 3 个安全凭证详解
git·gitee·github
李日灐19 小时前
< 7 > Linux 开发工具:git 版本控制器 和 cgdb/gdb 调试器
linux·运维·服务器·开发语言·git·调试器·gdb/cgdb
Gust of wind20 小时前
idea结合git和Gitee的初步使用
git·gitee·intellij-idea
夜七少eleanor20 小时前
【Git】2026全图文详解安装教程
git
海边的Kurisu20 小时前
从零开始的Git生活 | 刚实习同学的噩梦 And 参与开源不可缺的一环
git·生活
不老刘21 小时前
Git Cherry-Pick:微前端架构下的“精准医疗”与最佳实践
前端·git
爬楼的猪1 天前
Git Folder Dashboard
git