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%

相关推荐
范纹杉想快点毕业2 小时前
Qt、C++自定义按钮、组件、事件编程开发练习,万字实战解析!!
java·c语言·开发语言·c++·git·qt·github
stark张宇3 小时前
Centos7 安装部署Git服务、创建仓库
git·后端
Two_brushes.7 小时前
Git 实战场景
git
巴里巴气10 小时前
git常用操作 --- idea编译器 --- 公司实战版
git·idea
.鱼子酱11 小时前
FFmpeg 超级详细安装与配置教程(Windows 系统)
windows·ffmpeg
superkcl202212 小时前
【JAVA】【Stream流】
java·windows·python
炽天使32813 小时前
Git 日常操作流程(备查)
git·学习
jian1105815 小时前
windows清理系统备份文件夹WinSxS文件夹清理
windows
程序员王天19 小时前
Git Push 报错图解:从分支分叉到代码恢复
前端·git