git 询问用户凭据(Gitlab)

Ian*_*ako 3 git gitlab

我想对一个项目进行初步提交。Git 在线和本地存储库已经设置完毕,ssh 密钥也应该可以正常工作。我将用作example.com我的 git 服务器的参考。

当我打字时ssh git@gitlab.example.com我得到Welcome to GitLab, Name Surname!

当我尝试推送第一次提交时,git push --set-upstream origin master它要求提供用户凭据,但我不确定在哪里可以找到这些凭据。我从我的公司获得了登录名和密码,在 GitLab 上我的用户名是name.surname。我尝试了登录名/密码和用户名/密码的两种组合,但都说

remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.example.com/name.surname/project.git/
Run Code Online (Sandbox Code Playgroud)

后来我想直接在 Visual Studio 中实现连接,但同样的情况发生,当我想推送某些内容时,它会要求用户凭据。

mar*_*olz 5

您的远程 ( origin) 设置为httpsURL 而不是sshURL。

查看 的输出git remote show origin

您可以使用以下方法更改 URL:

git remote set-url origin git@gitlab.example.com:name.surname/project.git
Run Code Online (Sandbox Code Playgroud)