New: git remotes ssh url script

This commit is contained in:
Akemi Izuko 2023-01-22 11:29:09 -07:00
parent 7cb168aa81
commit a55af34364
No known key found for this signature in database
GPG key ID: 905D444F6A5E4BE4

19
bin/remotes_to_ssh.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Switch https git remote urls to ssh
git remote -v | awk '
/https:\/\// {
split($0, a, " ")
split(a[2], b, "/")
url = "ssh://git@"b[3]":22"
for (i = 4; i <= length(b); i++)
url = url"/"b[i]
if (url !~ /\.git$/)
url = url".git"
system(sprintf("git remote set-url %s %s", a[1], url))
printf "%s `%s` -> `%s`\n", a[1], a[2], url
}
'