--- /dev/null
+#! /bin/sh
+# See https://stackoverflow.com/q/77560684/7976758
+
+# Uses a transient repository so it's not effective to resolve many URLs.
+# For many URLs create one repository, add remotes,
+# get rewritten URLs and then remove the repository.
+
+set -e
+
+if [ $# -ne 1 ]; then
+ echo "Usage $0 URL" >&2
+ exit 1
+fi
+
+cd /tmp
+rm -rf _git_resolve_remote.tmp
+git init --quiet _git_resolve_remote.tmp
+cd _git_resolve_remote.tmp
+
+git remote add origin "$1"
+git remote get-url origin
+
+cd ..
+exec rm -rf _git_resolve_remote.tmp