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%

相关推荐
Master_H_ice2 小时前
Claude Code安装试用记录(Windows)
windows·claude code
芳草萋萋鹦鹉洲哦5 小时前
【windows】nginx如何注册为开机自启的服务(WinSW实现)
运维·windows·nginx
好名字更能让你们记住我5 小时前
vmware虚拟机安装Windows10镜像【超详细图文版】!!!
windows·系统安装·vmware·虚拟机·图文教程
副露のmagic6 小时前
字符串章节 leetcode 思路&实现
windows·python·leetcode
Java 码农6 小时前
Windows 系统安装 Claude Code 完整教程
windows
海参崴-7 小时前
【Linux 项目自动化构建工具 -- make/makefile && 版本管理 Git 的使用&&第一个程序
linux·git·自动化
W-琑8 小时前
Git基本操作及操作原理
git
无籽西瓜a9 小时前
详解bat脚本:语法、常见用法、注意事项、示例
windows·batch·cmd·自动化工具
流星雨在线10 小时前
项目 Git 分支 + Tag 管理规范
git
爱宇阳10 小时前
Git Clone 完整入门指南(从 0 到团队实战)
git