Git ssh:Could not resolve hostname


Solution to the problem:

Remote repository URL ssh://

Cloning a repository

If an error occurred during cloning, just use the URL without specifying the ssh:// scheme using the URL view.

git clone git@gitlab.com:xorcare/example.git

Instead

git clone ssh://git@gitlab.com:xorcare/example.git

Working with the repository

If you stop working with the commands git push, git fetch and others, with host permission, check the URL format of the remote repositories git remote -v

origin ssh://git@gitlab.com:/xorcare/example (fetch)
origin ssh://git@gitlab.com:/xorcare/example (push)

ssh:// `remove it and cast it to the following form

origin git@gitlab.com:/xorcare/example (fetch)
origin git@gitlab.com:/xorcare/example (push)

git settings

Git, it may be that the setting instead can automatically change the address of the remote repository, even if you use a different URL.

Check ~/.gitconfig and .git/config for a modifying URL instead

[url "ssh://git@gitlab.com:"]
Instead = https://gitlab.com/
pushInsteadOf = https://gitlab.com/

and remove ssh:// for remote addresses to work correctly.

Errors log

user@hostname:~/work/repository$ git fetch
ssh:Could not resolve hostname gitlab.com:xorcare:Name or service not known
fatal:Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
user@hostname:~/work/repository$ git clone ssh://git@gitlab.com:xorcare/example.git
Cloning into 'xor.care'...
ssh:Could not resolve hostname gitlab.com:xorcare:Name or service not known
fatal:Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.