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%

相关推荐
张人玉5 小时前
WinForm之ListBox 控件
服务器·windows·microsoft
程序视点6 小时前
Windows桌面美化神器MyDockFinder:让你的电脑瞬间拥有macOS风格界面
windows·macos·mac
CV资深专家7 小时前
常用git命令
git
bug和崩溃我都要9 小时前
Git提交代码完整流程
git
逢考必过@k9 小时前
git的使用
git
狂炫一碗大米饭14 小时前
如何在 Git 中检出远程分支
前端·git·github
程序视点15 小时前
FDM下载神器:免费多线程下载工具,速度90+M/S,完美替代1DM!
windows·后端
aiprtem15 小时前
LVGL + ESP-Brookesia 在Windows下的编译和运行
windows·物联网
dolzhuying16 小时前
git常见场景食用指南
git
上邪o_O17 小时前
Git 的基本使用指南(1)
linux·git