Last active
March 17, 2022 13:46
-
-
Save mamemomonga/1d90dde2f74f47c031048fc35b153122 to your computer and use it in GitHub Desktop.
カレントディレクトリ以下に含まれるGitのリモートリポジトリのホスト名を一括して書き換える。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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