You can't tell Git to suppress the error, if it already exists you either need to remove it and re-add it, or update its URL. Suppressing the error for mkdir
is OK, because if it exists you don't need to make it. With a Git remote that's not true, because the existing one might have a different URL, so just ignoring the command isn't OK if it fails.
Assuming this is some script that you are trying to change (otherwise if it's a manual process on the command line then just ignore the error and get on with something more important) there are two simple solutions I can see:
check for the remote first, and either update it or add it, as appropriate:
if git remote | grep -w godaddy ; then
git remote set-url godaddy $user1@foo.com:root.git
else
git remote add godaddy $user1@foo.com:root.git
fi
just try adding it and if that fails then update the URL:
git remote add godaddy $user1@foo.com:root.git || git remote set-url godaddy $user1@foo.com:~/root.git
Another option would be to redirect stderr to /dev/null
and make the command return true even git
exits with an error, but that's probably not a good idea:
git remote add godaddy $user1@foo.com:root.git 2>/dev/null || true