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%

相关推荐
Light609 小时前
领码方案|Windows 下 PLT → PDF 转换服务超级完整版:异步、权限、进度
windows·ghostscript.net·权限治理·异步转换·进度推送·redis 存储·kubernetes 部署
会豪10 小时前
Git命令-图解-小白专享
git
韦禾水10 小时前
IntelliJ IDEA 2023更新git凭据
git·intellij idea
Yvonne爱编码11 小时前
构建高效协作的桥梁:前后端衔接实践与接口文档规范详解
前端·git·ajax·webpack·node.js
@CLoudbays_Martin1112 小时前
CDN是否能有效检测并且同时防御Ddos 和 CC 攻击?
java·服务器·网络·数据库·git·数据库开发·时序数据库
染指111012 小时前
11.ImGui-加载字体和中文
c++·windows·imgui
李游Leo13 小时前
Rust 开发环境安装与 crates.io 国内源配置(Windows / macOS / Linux 全流程)
windows·macos·rust
小王不爱笑13214 小时前
Java基础知识(十四)
java·windows·python
sc_yhsheng14 小时前
18j621-3通风天窗图集pdf(免费高清版)
windows·pdf
程序员TNT15 小时前
Shoptnt 促销计算引擎详解:策略模式与责任链的完美融合
linux·windows·策略模式