This prevents that the push rule is added multiple times to .git/config if a
fetch failed.
echo "Adding remote '$2' to '$1'."
git remote add -t master "$2" "$3/$1"
git fetch "$2" > /dev/null
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.
+ # Remove the remote and abort if the fetch was unsuccessful.
if [ "$?" -ne "0" ]; then
git remote rm "$2"
if [ "$?" -ne "0" ]; then
git remote rm "$2"
fi
# Pushing to the remote pushes only the master branch in remotes named
fi
# Pushing to the remote pushes only the master branch in remotes named