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提取当前分支指定文件历史版本
git
数字游民95275 分钟前
网站备案全流程回放(腾讯云)
人工智能·git·github·腾讯云·网站备案·waytoopc
雪域迷影9 分钟前
Windows11上安装Redis服务和Redis可视化客户端
windows·redis
广然10 分钟前
Windows 11 关闭 VBS 的几种方法
windows·ensp·vbs
不染尘.13 分钟前
Linux基本概述
linux·windows·centos·ssh
Albert Edison39 分钟前
【Git】多人协作一(同一分支下)
git·vscode·svn·github
学好statistics和DS1 小时前
Git 同步冲突
大数据·git·elasticsearch
郑泰科技1 小时前
快速地图匹配(FMM)的开源工具与代码示例
c++·windows·python·交通物流
张世争11 小时前
windows clion MingW cmake 编译运行 FreeRTOS
windows·freertos·mingw·cmake·clion
AI 智能服务12 小时前
第6课__本地工具调用(文件操作)
服务器·人工智能·windows·php