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%

相关推荐
chilavert3181 小时前
技术演进中的开发沉思-31 MFC系列:类层次结构
c++·windows
dongzhenmao6 小时前
P1484 种树,特殊情形下的 WQS 二分转化。
数据结构·c++·windows·线性代数·算法·数学建模·动态规划
EutoCool7 小时前
Qt:布局管理器Layout
开发语言·c++·windows·嵌入式硬件·qt·前端框架
Otaku love travel8 小时前
实施运维文档
运维·windows·python
浩浩测试一下9 小时前
Windows 与 Linux 内核安全及 Metasploit/LinEnum 在渗透测试中的综合应用
linux·运维·windows·web安全·网络安全·系统安全·安全架构
落雪小轩韩11 小时前
Git 常用操作与注意事项全攻略
大数据·git
winds~11 小时前
【Git】git的回退功能
大数据·git·elasticsearch
Ring__Rain11 小时前
git fetch的使用
git
188_djh13 小时前
# 电脑每次重启都自动启动惠普安装程序,怎么取消?
windows·任务管理器·惠普打印机·msconfig·hpsmartinstall·安装程序自动启动·系统配置工具
甜甜不吃芥末13 小时前
Windows 应用程序的 UI 框架:WPF、WinUI 3 和 UWP的差异区别
windows·ui·wpf