# 定义基础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
相关推荐
rockmelodies19 小时前
Git冲突解决实用指南bj_zhb19 小时前
Git 回退到某个 commit凯子坚持 c19 小时前
Git分支实战指南:如何优雅地管理版本、修复Bug并解决合并冲突openinstall全渠道统计20 小时前
开发者指南:广告投放系统搭建与前后端数据打通全流程yunianshu20 小时前
在 DevEco Studio 中查看 Git 本地更改 (Local Changes) 指南脾气有点小暴20 小时前
git commit 的提交如何撤销winner888120 小时前
Git撤销修改:git restore . 与 git reset --hard 万字详解我的offer在哪里21 小时前
SourceTree 全方位使用教程Irene19911 天前
查看是否已安装 Git 的方法my_power5201 天前
检出git项目到android studio该如何配置