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%

相关推荐
jiayong2310 小时前
Git 核心概念:Tag 与 Branch 的本质区别
git
玉梅小洋10 小时前
Windows 10 Android 构建配置指南
android·windows
Serene_Dream13 小时前
git 合并冲突的分支
git
我是一只puppy13 小时前
使用AI进行代码审查
javascript·人工智能·git·安全·源代码管理
玄同76514 小时前
Git常用命令指南
大数据·git·elasticsearch·gitee·github·团队开发·远程工作
雨中风华16 小时前
Linux, macOS系统实现远程目录访问(等同于windows平台xFsRedir软件的目录重定向)
linux·windows·macos
十步杀一人_千里不留行17 小时前
Git提交前ESLint校验实践(Husky + lint-staged)
git·github
yuuki23323318 小时前
【C++】继承
开发语言·c++·windows
非凡ghost19 小时前
PowerDirector安卓版(威力导演安卓版)
android·windows·学习·软件需求
hh随便起个名20 小时前
适合小白的git的基础使用方法
git