dotfiles/bin/grts

11 lines
322 B
Bash
Executable File

#!/usr/bin/env bash
# Converts a http(s) remote to an ssh one
remote=$(git remote -v | grep origin | head -n 1 | cut -d $'\t' -f 2 | cut -d ' ' -f 1)
server=$(echo $remote | cut -d '/' -f 3)
user=$(echo $remote | cut -d '/' -f 4)
repo=$(echo $remote | cut -d '/' -f 5)
git remote set-url origin git@$server:$user/$repo