主要是文本编码问题(echo "research/deeplab" >> .git/info/sparse-checkout),我电脑上使用windows自带的terminal和power shell时使用echo指令写入文件发现文件的编码是utf-16 le (可能是之前瞎捣鼓的问题),可以用vscode等编辑器打开sparse-checkout将编码改为utf-8再填写路径保存(使用git bash用echo写入也没问题)。
文末附上git clone指定目录的方式
![terminal上power shell使用echo写入](https://i-blog.csdnimg.cn/blog_migrate/308f6d176bd621a8a520822dc8e7f9cd.png)
![修改编码重新输入保存](https://i-blog.csdnimg.cn/blog_migrate/c0bbdc153a08ef880ad9ffc144872ff9.png)
git clone指定子目录
mkdir project
cd project
git init
git config core.sparsecheckout true
echo "Notes in Markdown" >> .git/info/sparse-checkout #路径从根目录开始(不带仓库名的)
git remote add origin git@github.com:Nagi-ovo/Cherno-CPP-Notes.git
git pull origin master