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%

相关推荐
海盗12341 小时前
微软技术日报·2026-08-12——Windows 11多通道累积更新推送十余项功能改进;.NET WebSocket DoS紧急修复
windows·microsoft·.net
for_ever_love__16 小时前
python基础语法学习: 数据容器
windows·python·学习
huainingning18 小时前
微软windows系统官网IPV6临时地址介绍
windows·microsoft·智能路由器
Geek-Chow1 天前
Git 标签与发布流程:轻量标签、附注标签与签名标签
git·tags
wear工程师1 天前
Git 冲突怎么解决:别只删标记,先看懂暂存区的 1、2、3 阶段
git
村雨遥1 天前
覆盖提交不等于删除,这才是彻底清除 Git 历史的正确姿势
git·github
.Peter1 天前
.NET/WPF 程序在部分 Windows 电脑无法保存用户环境变量:使用 DPAPI 实现安全兼容
windows·信息安全·c#·.net·wpf·环境变量·dpapi
淮北4941 天前
ubuntu22 默认输入法调整频率
运维·服务器·git·ubuntu·elasticsearch
码字的特恩1 天前
微软确认暂不为 Windows 11 加入透明效果自定义功能,建议用户使用第三方工具
人工智能·windows·算法·microsoft·计算机·大模型·编程
神奇小梵1 天前
安全和开发的需要了解的知识————下载内容的安全,和下载内容如何运行
android·windows·安全·个人开发