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

相关推荐
NaCl鱼呜啦啦11 小时前
Git 仓库损坏修复指南:从诊断到恢复
git
huazi9912 小时前
AI编程(一):Trae+Git 应用开发
git·ai编程·trae
badhope14 小时前
GitHub热门AI技能Top20实战指南
前端·javascript·人工智能·git·python·github·电脑
m0_6356474816 小时前
git管理github上的repository(三)
git·github
圥忈&&丅佽&&扗虖16 小时前
ubuntu 安装git
linux·git·ubuntu
好运yoo18 小时前
git fetch和git pull的区别
大数据·git·elasticsearch
薛不痒18 小时前
github基础入门(3):版本控制(提交,分支删除,提交规范)
大数据·windows·git·elasticsearch·github
摇滚侠1 天前
git 把已经推送到远程仓库的文件取消被 git 管理
git
007张三丰1 天前
掌握核心!Git最常用的15个命令行:从入门到实战详解
git·gitlab·github·git命令行·常用命令行
月光下的麦克1 天前
Git 打 Tag 的作用
git