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

相关推荐
our_times22 分钟前
# Git 高频命令实战指南:从日常开发到进阶协作
git
PBitW1 小时前
git 中容易遗忘的点 (二) ⚡⚡⚡
前端·git·面试
PBitW1 小时前
git 中容易遗忘的点 (三) 🚀🚀🚀
前端·git·面试
北极糊的狐5 小时前
钉钉小程序 Git 版本管理完整流程
git·小程序·钉钉
Fzuim14 小时前
当 AI 也成为提交者:ThinkFlow 的 Git 提交规范,是怎么定的
git·agent·thinkflow
CodexDave1 天前
数据库连接池耗尽:排查顺序与三层兜底
服务器·前端·数据库·git·云原生·容器·kubernetes
乐观的Terry1 天前
5、发布系统-Git 集成
大数据·git·elasticsearch
不怕犯错,就怕不做1 天前
GIT的简单打patch应用format-patch and git am
linux·git·全文检索
Byron Loong1 天前
【Git】如何检查 Ubuntu 系统上 gitLab 是否开启
git·ubuntu·gitlab
lar_slw1 天前
git删除上一次提交
git