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%

相关推荐
怣502 小时前
Windows 11 临时文件清理完全指南:释放宝贵磁盘空间
windows·清理c盘
热爱生活的五柒4 小时前
WebDAV如何使用?
windows
无限进步_4 小时前
面试题 02.02. 返回倒数第 k 个节点 - 题解与详细分析
c语言·开发语言·数据结构·git·链表·github·visual studio
2401_859049084 小时前
git submodule update --init --recursive无法拉取解决
前端·chrome·git
面对疾风叭!哈撒给5 小时前
Windows 系统使用NSSM创建 Windows服务
windows
MyBFuture6 小时前
C#数组详解:一维二维与交错数组
开发语言·windows·c#·visual studio·vision pro
生活很暖很治愈6 小时前
GUI自动化测试[3]——控件&数鼠标操作
windows·python·功能测试·测试工具
HAPPY酷6 小时前
构建即自由:一份为创造者设计的 Windows C++ 自动化构建指南
开发语言·c++·ide·windows·python·策略模式·visual studio
忘忧记7 小时前
某小说数据分析过程
windows·数据挖掘·数据分析
PPPPPaPeR.7 小时前
环 境 变 量
linux·运维·windows