Skip to content

Instantly share code, notes, and snippets.

@doekman doekman/git-url.sh
Last active Jul 7, 2019

Embed
What would you like to do?
Prints the URL of the remote origin of the current git repository
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS=$'\n\t'
function git_url_to_https {
local git_url
git_url=$(cat)
if [[ $git_url =~ ^git@([^:]+):(.+)(\.git)?$ ]]; then
git_url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
fi
if [[ -n $git_url ]]; then echo "$git_url"; fi
}
git config --get remote.origin.url | git_url_to_https
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.