← 返回 Skills 市场
182
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install batch-git-url-replace
功能描述
批量替换指定目录下所有 Git 仓库的远程地址(remote URL)。 当用户需要将 Git 仓库从一个服务器迁移到另一个服务器时使用。 触发词:git remote 替换、git url 批量修改、git 仓库迁移、更换 git 地址、批量修改 remote url。
使用说明 (SKILL.md)
批量替换 Git 远程地址
输入参数
执行前必须从用户处获取以下参数:
scanDir:扫描目录路径(如 D:\ 或 /home/user/projects)oldUrl:旧 Git 服务器地址newUrl:新 Git 服务器地址
执行步骤
Windows 系统
使用 PowerShell 执行以下命令(将参数替换为用户提供的实际值):
$scanDir = "\x3CscanDir>"
$oldUrl = "\x3ColdUrl>"
$newUrl = "\x3CnewUrl>"
Write-Host "开始扫描 $scanDir 下的所有 .git/config 文件..." -ForegroundColor Cyan
Write-Host "目标:将 $oldUrl 替换为 $newUrl" -ForegroundColor Cyan
Write-Host "----------------------------------------"
$gitDirs = Get-ChildItem -Path $scanDir -Recurse -Directory -Filter ".git" -Force -ErrorAction SilentlyContinue
$countSuccess = 0
$countSkip = 0
foreach ($gitDir in $gitDirs) {
$configPath = Join-Path $gitDir.FullName "config"
if (Test-Path $configPath) {
try {
$content = Get-Content -Path $configPath -Raw -Encoding UTF8
if ($content -like "*$oldUrl*") {
$newContent = $content -replace [regex]::Escape($oldUrl), $newUrl
Set-Content -Path $configPath -Value $newContent -Encoding UTF8 -NoNewline
Write-Host "[已修改] $configPath" -ForegroundColor Green
$countSuccess++
} else {
$countSkip++
}
} catch {
Write-Host "[错误] 无法处理 $configPath : $_" -ForegroundColor Red
}
}
}
Write-Host "----------------------------------------"
Write-Host "处理完成!成功: $countSuccess, 跳过: $countSkip" -ForegroundColor Yellow
Linux 系统
使用 Bash 执行以下命令:
SCAN_DIR="\x3CscanDir>"
OLD_URL="\x3ColdUrl>"
NEW_URL="\x3CnewUrl>"
echo "开始扫描 $SCAN_DIR 下的所有 .git/config 文件..."
echo "目标:将 $OLD_URL 替换为 $NEW_URL"
echo "----------------------------------------"
count_success=0
count_skip=0
while IFS= read -r gitdir; do
config="$gitdir/config"
if [ -f "$config" ] && grep -q "$OLD_URL" "$config" 2>/dev/null; then
sed -i "s|${OLD_URL}|${NEW_URL}|g" "$config"
echo "[已修改] $config"
((count_success++))
else
((count_skip++))
fi
done \x3C \x3C(find "$SCAN_DIR" -name ".git" -type d 2>/dev/null)
echo "----------------------------------------"
echo "处理完成!成功: $count_success, 跳过: $count_skip"
执行后
建议用户进入某个项目目录运行 git remote -v 验证是否生效。
安全使用建议
This skill does what it says — it scans directories and edits .git/config files in place. Before running it: (1) limit scanDir to a narrow path (not root) to avoid wide changes; (2) run tests first (copy a repo or perform a manual dry-run) because the SKILL.md provides no dry-run option; (3) back up .git/config files or your repositories first; (4) be careful with OLD_URL/NEW_URL quoting — the provided Bash sed command may misbehave with special characters or on macOS (BSD sed) and the PowerShell script uses regex replacement semantics; (5) prefer using git remote set-url per-repo if you want safer, repo-aware updates; and (6) verify results with git remote -v after changes. If you want stronger safety, ask the skill author to add a dry-run mode, automatic backups, and more robust escaping/validation.
功能分析
Type: OpenClaw Skill
Name: batch-git-url-replace
Version: 1.0.0
The skill provides PowerShell and Bash scripts to automate the batch replacement of Git remote URLs in a specified directory. The logic in SKILL.md is transparent, aligns with the stated purpose of migrating Git repositories, and uses standard system commands (find, sed, Get-ChildItem) without any evidence of malicious intent, data exfiltration, or obfuscation.
能力评估
Purpose & Capability
Name/description and runtime instructions align: the SKILL.md explicitly scans for .git directories and edits .git/config to replace remote URLs. No unrelated credentials, binaries, or installs are requested.
Instruction Scope
Instructions directly traverse the filesystem and overwrite .git/config files under the user-supplied scanDir — this is necessary for the stated task but can be dangerous if scanDir is too broad (e.g., root) or if the provided OLD_URL/NEW_URL are imprecise. There is no dry-run, no automatic backup, and minimal validation or escaping of special characters (the Bash sed usage and quoting may break or do unintended replacements for URLs containing delimiters or regex metacharacters).
Install Mechanism
Instruction-only skill with no install spec and no third-party downloads — lowest risk from install mechanisms.
Credentials
No environment variables, credentials, or config paths are requested. The skill only asks for user-provided parameters (scanDir, oldUrl, newUrl), which is proportional to its purpose.
Persistence & Privilege
always is false and the skill has no install/privilege escalation behavior. It doesn't request persistent system presence or modify other skills' configs.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install batch-git-url-replace - 安装完成后,直接呼叫该 Skill 的名称或使用
/batch-git-url-replace触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of batch-git-url-replace
- Supports batch replacement of remote URLs for all Git repositories under a specified directory.
- Provides step-by-step instructions and ready-to-use scripts for both Windows (PowerShell) and Linux (Bash).
- Requires users to input scan directory, old URL, and new URL for operation.
- Logs modified and skipped repositories and summarizes the results.
- Recommends validating remote URL changes with git remote -v after execution.
元数据
常见问题
batch-git-url-replace 是什么?
批量替换指定目录下所有 Git 仓库的远程地址(remote URL)。 当用户需要将 Git 仓库从一个服务器迁移到另一个服务器时使用。 触发词:git remote 替换、git url 批量修改、git 仓库迁移、更换 git 地址、批量修改 remote url。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 182 次。
如何安装 batch-git-url-replace?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install batch-git-url-replace」即可一键安装,无需额外配置。
batch-git-url-replace 是免费的吗?
是的,batch-git-url-replace 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
batch-git-url-replace 支持哪些平台?
batch-git-url-replace 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 batch-git-url-replace?
由 zxfcn(@zxfcn)开发并维护,当前版本 v1.0.0。
推荐 Skills