# 定义基础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会在执行完毕后自动退出
powershell脚本批量拉取 git仓库文件
—Phoenix2024-05-25 10:53
相关推荐
ShineWinsu11 小时前
对于Git:远程操作的超详细保姆级解析梦帮科技12 小时前
从 Guest 到 Platinum:Prompt 配额、API Key 与访问控制的安全闭环zho_uzhou1 天前
Git入门概念爱奥尼欧2 天前
【Git】远程分支删了本地还在、两个分支历史不相干?两招故障排解Java后端的Ai之路2 天前
Git冲突完整排查与实战:本地修改覆盖报错到成功推送全流程复盘一个心烑2 天前
配置项目git的 SSL 证书IT从业者张某某2 天前
【鸿蒙PC命令行适配】GitUI 移植的工程实践:双 Git 引擎(libgit2/gitoxide)的鸿蒙适配之路xinjia_ctrl2 天前
暑假实习总结Molesidy2 天前
【Git】分别给出添加到Keil工程和IAR工程中的gitnore文件以便不跟踪编译文件的git记录颜颜yan_2 天前
Git Cola 鸿蒙 PC 版适配全记录:从 Qt 桌面工具到 ArkTS 原生应用