#!/bin/sh # Use this tool to rewrite your .git/remotes/ files into the config. source git-sh-setup if test -d "$GIT_DIR"/remotes { echo "Rewriting $GIT_DIR/remotes" >&2 setvar error = '0' # rewrite into config do { cd "$GIT_DIR"/remotes ls | while read f { setvar name = $(printf "$f" | tr -c "A-Za-z0-9-" ".") sed -n \ -e "s/^URL:[ ]*\(.*\)$/remote.$name.url \1 ./p" \ -e "s/^Pull:[ ]*\(.*\)$/remote.$name.fetch \1 ^$ /p" \ -e "s/^Push:[ ]*\(.*\)$/remote.$name.push \1 ^$ /p" \ < "$f" } echo done } | while read key value regex { case (key) { done { if test $error = 0 { mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old } } * { echo "git config $key "$value" $regex" git config $key $value $regex || setvar error = '1' } } } }