Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Last active March 17, 2022 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamemomonga/1d90dde2f74f47c031048fc35b153122 to your computer and use it in GitHub Desktop.
Save mamemomonga/1d90dde2f74f47c031048fc35b153122 to your computer and use it in GitHub Desktop.
カレントディレクトリ以下に含まれるGitのリモートリポジトリのホスト名を一括して書き換える。
#!/usr/bin/env perl
# -------------------------------------
# 要 IO:All (cpanm install IO::All)
# 必ずバックアップを行ってから実行すること
# -------------------------------------
use strict;
use warnings;
use feature 'say';
use File::Find;
use Data::Dumper;
use IO::All;
my $hostFrom="oldHost.domain";
my $hostTo ="newHost.domain";
my @lists;
find(sub {
my $name=$File::Find::name;
if($name=~m!\Q/.git/config\E!) {
push @lists,$name;
}
},'.');
foreach my $fn(@lists) {
say "[$fn]";
my $buf=io($fn)->all;
$buf=~s!url = git\@$hostFrom!url = git\@$hostTo!g;
io($fn)->print($buf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment