addr="`echo $remote | cut -d ' ' -f 2`"
type="`echo $remote | cut -d ' ' -f 3`"
- if [ "$type" == "(push)" ]; then
- command="set-url --add --push"
- else
- command="add"
- fi
-
if ! git remote -v | sed -e 's/\t/ /g' | grep -q "^$name $addr $type$"; then
- # This might not sync everything in the first run as some weird behavior.
+ # Check if was not already added by a previous command
+ if ! git remote | grep -q "^$name$"; then
+ git remote add $name $addr
+ fi
+
+ # This might not sync everything in the first run due to unreliable "git remote -v" output.
# See https://github.com/git/git-scm.com/issues/886
- git remote $command $name $addr
+ #if [ "$type" == "(push)" ]; then
+ # git remote set-url --add --push $name $addr
+ #fi
+ git remote set-url --add --push $name $addr
fi
done