windows中通过git从远程快速只下载指定一个文件的批处理命令

@echo off

setlocal enabledelayedexpansion

@REM 这里填实际文件名

set "fileName=test.json"

@REM 这里填实际分支名

set "branchName=dev"

@REM 这里填实际源码地址

set "repoUrl=https://xxx/demo.git"

set "tmpDir=%~dp0tmp"

set "targetFile=%~dp0%fileName%"

if exist %tmpDir% (rd /S /Q %tmpDir%)

mkdir %tmpDir%

git clone --depth 1 --branch %branchName% %repoUrl% %tmpDir%

cd /d "%tmpDir%"

git config core.sparsecheckout true

echo %fileName% >> .git/info/sparse-checkout

git checkout %branchName%

cd /d "%~dp0"

move /Y %tmpDir%\%fileName% "%targetFile%" >nul

rd /S /Q %tmpDir%

相关推荐
艺杯羹11 小时前
Windows原生软件锁设计:从暴力杀进程丢数据到零轮询事件驱动架构
windows·系统架构·开源·开源软件·内存管理·开源协议
csdn_aspnet19 小时前
Redis 入门:Windows、Mac安装指南
数据库·windows·redis·缓存·mac
没差c2 天前
winsw将jar、nginx等注册为Windows服务
windows·nginx·jar
高调的涵涵2 天前
删了1.2GB,.git仍是1.2GB
git
光谱SpectrAI2 天前
Claude Code 2.1.318 的隐私模块:4 条命令,拦了 2 条
windows
程序员沉梦听雨2 天前
【Git】git-submodule子模块管理
git
Hello_Pyhx2 天前
NWinfo 导出 Windows 硬件信息:从 JSON 报告到缺项排查
windows·json
百事牛科技3 天前
Excel的三种密码:防看、防存、防乱改,各管各的
windows·excel
全栈陈序员3 天前
Git】从入门到精通(八)—— git log:查看提交历史
大数据·git·elasticsearch
7177773 天前
Git自建用什么工具比较好:Gitea、Forgejo、GitLab CE与Gitee的选型对比
git·gitlab·gitea