gitgitlab

ssh: Could not resolve hostname git: Name or service not known fatal: Could not read from remote repository


After I switched from HTTPS to SSH for my repo then I received this error when pushing to origin master:

ssh: Could not resolve hostname git: 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.

I also add my ssh in the gitlab. What should I do?


Solution

  • I was getting the same error.

    This error typically occurs when there is an issue with the SSH configuration or the Git remote repository's hostname cannot be resolved.

    Here, you can check your remote by running:

    git remote -v
    

    There are few reasons why this error occurs:

    Typically, you can solve this by Change the [remote "origin"] URL value in .gitconfig or .config/git/config or .git/config/ file

    Previously:

    https://git@github.com:userName/repo.git
    

    OR

    ssh://git@github.com:userName/repo.git
    

    New:

    git@github.com:userName/repo.git