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%

相关推荐
一只大袋鼠4 小时前
Git 进阶(二):分支管理、暂存栈、远程仓库与多人协作
java·开发语言·git
木心术18 小时前
Windows系统下MySQL与AI工具集成方案:数据存储与调用实践
人工智能·windows·mysql
beyond阿亮9 小时前
Hermes Agent快速接入 QQ 完整教程|QQ聊天使用AI智能体
人工智能·windows·ai·openclaw·hermes agent
DONSEE广东东信智能读卡器9 小时前
用PowerShell实现Windows 本地 WSS/HTTPS 自签名证书配置方法
windows·网络协议·https·powershell·身份证阅读器
我叫张小白。11 小时前
Git 分支管理与团队协作
git
DogDaoDao12 小时前
Windows 下 Git 报错:`touch` 无法识别 —— 原因分析与 7 种解决方案(从入门到精通)
windows·git·程序员·npm·powershell·cmd·touch
caicai_xiaobai13 小时前
Ubuntu上Git安装步骤
linux·git·ubuntu
Ai.den13 小时前
Windows 安装 MinerU 3.x 实现本地批量解析 PDF
人工智能·windows·ai
xfddlm13 小时前
在Windows上配置Claude Code
windows
AI行业学习14 小时前
Notepad++ 下载+安装+插件集合 完整教程(Windows,安全无捆绑)
windows·notepad++