get git remote url as https
. Whatever your remote Git repository settings are.
use it :
- for github.com repo :
git-remote-http.sh
get first repo https url as ordered by git.git-remote-http-all.sh
get all repo https url as ordered by git.
MIT
#!/usr/bin/env bash | |
set -e | |
[ -z "${GITHOST}" ] && GITHOST="github.com" | |
[ -z "${GITBRANCH}" ] && GITBRANCH="origin" | |
git remote -v \ | |
| grep "${GITBRANCH}" | grep fetch | while read -r line ; do \ | |
cat <<< "${line}" \ | |
| sed -re 's~\s+\(fetch\)$~~' \ | |
-re 's~([^/ :]+/[^/ :]+)$~#\1~;s~^[^#]+#+~~' \ | |
-re 's~(github\.com)~\1/~' \ | |
-re '/^https?:\/\//!s~^~https://'"${GITHOST}"'/~' | |
done |
#!/usr/bin/env bash | |
set -e | |
[ -z "${GITHOST}" ] && GITHOST="github.com" | |
[ -z "${GITBRANCH}" ] && GITBRANCH="origin" | |
git remote -v \ | |
| grep "${GITBRANCH}" | grep fetch | head -n 1 \ | |
| sed -re 's~\s+\(fetch\)$~~' \ | |
-re 's~([^/ :]+/[^/ :]+)$~#\1~;s~^[^#]+#+~~' \ | |
-re 's~(github\.com)~\1/~' \ | |
-re '/^https?:\/\//!s~^~https://'"${GITHOST}"'/~' |