powershell脚本批量拉取 git仓库文件

复制代码
# 定义基础URL和数据库列表  
$BASE_URL = "http://8.8.11.99:8999/yaya/"  
$DATABASES = "common-service", "bi-system", "erp", "gateway", "pdm", "plm", "public-service", "scm", "ums", "wms"  
  
# 遍历数据库列表  
foreach ($prj in $DATABASES) {  
    # 构建仓库URL和本地路径  
    $RepoURL = $BASE_URL + $prj + ".git"  
    $LocalRepoPath = ".\$prj"  
    $Dbranch = "test"  
  
    # 检查本地目录是否存在,如果不存在则克隆仓库  
    if (!(Test-Path -Path $LocalRepoPath)) {  
        Write-Host "Cloning $RepoURL to $LocalRepoPath ..."  
        git clone $RepoURL $LocalRepoPath  
        if ($LASTEXITCODE -ne 0) {  
            Write-Host "Failed to clone $RepoURL"  
        } else {  
            # 切换到特定分支并拉取更新(如果需要)  
            cd $LocalRepoPath  
            git checkout $Dbranch  
            git pull  
        }  
        cd .. # 返回到上级目录  
    } else {  
        Write-Host "Repository $RepoURL already exists locally at $LocalRepoPath"  
    }  
}  
  
# 暂停以查看输出(如果需要)  
# Read-Host -Prompt "Press Enter to continue..."  
  
# 脚本结束,不需要显式退出,因为PowerShell会在执行完毕后自动退出
相关推荐
码厂一粒沙11 小时前
【代码管理】git使用指南(新手向)
git
李贺梖梖19 小时前
Git初识
git
~央千澈~19 小时前
git大文件储存机制是什么-为什么有大文件会出错并且处理大文件非常麻烦-优雅草卓伊凡
git
Komorebi_999921 小时前
Git 常用命令完整指南
大数据·git·elasticsearch
stark张宇1 天前
Git 与 GitHub 协同工作流:从0到1搭建版本控制体系
git·gitlab·github
爱吃生蚝的于勒1 天前
【Linux】零基础学会Linux之权限
linux·运维·服务器·数据结构·git·算法·github
minji...1 天前
Linux相关工具vim/gcc/g++/gdb/cgdb的使用详解
linux·运维·服务器·c++·git·自动化·vim
Arva .2 天前
开发准备之日志 git
spring boot·git·后端
奇某人2 天前
【嵌入式】【GIT】终端中文乱码修复
git
可爱的蜗牛牛2 天前
上传本地git所有历史记录到已有远程仓库
git