This makes fixing the remote easier as it's not necessary to remove it before
trying to add it again.
echo "Adding remote '$2' to '$1'."
git remote add -t master "$2" "$3/$1"
git fetch "$2" > /dev/null
+ # Remove the remote if the fetch was unsuccessful.
+ if [ "$?" -ne "0" ]; then
+ git remote rm "$2"
+ fi
+
# Pushing to the remote pushes only the master branch in remotes named
# the hostname of this machine. This makes it easy to see where
# changes came from.