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

相关推荐
日光倾4 小时前
【Vue.js 入门笔记】Git入门
笔记·git
dreams_dream6 小时前
Git 的 Tag
git
码农阿豪16 小时前
Jenkins Git 克隆失败深度解析:从 “Connection reset by peer“ 到彻底解决
运维·git·jenkins
独自破碎E17 小时前
VS Code图形化界面操作Git
git
我 see your eyes1 天前
Git操作流程
git
亮子AI1 天前
【Git】如何移除已经跟踪的文件/文件夹?
git
Lucis__1 天前
版本控制器git及gdb调试技巧深度剖析
git·gdb·开发工具
番茄去哪了2 天前
苍穹外卖day05----店铺营业状态设置
java·数据库·ide·redis·git·maven·mybatis
键盘鼓手苏苏3 天前
Flutter for OpenHarmony:git 纯 Dart 实现的 Git 操作库(在应用内实现版本控制) 深度解析与鸿蒙适配指南
开发语言·git·flutter·华为·rust·自动化·harmonyos