我最近在用我的 Github 帐户登录的 gitlab 上创建了一个项目。
但是当使用 gitbash 克隆项目(将我当前的 ssh-key 添加到 gitlab 帐户)时,shell 会提示输入用户名/密码,从 github 输入我的用户名和密码会导致身份验证失败。(电子邮件/密码也失败)
我做错了什么?
截至 2020 年 4 月 28 日下午 4:00(菲律宾标准时间)更新,包含私人回购范围。
如果您尚未设置密码或受 2FA 保护,则需要从您的 GitLab 帐户创建访问令牌。
api作为新访问令牌的范围。如果您从事私人项目,还请包括read_repository和write_repository范围。


像对待密码一样对待您的访问令牌!保持下一个访问令牌的范围较低,并且只与您信任的人共享。因为我在此处共享了示例令牌,所以任何使用它的尝试现在都会触发错误,因为我在更新答案之前撤销了它。
然后,尝试在使用时登录git push。
## Init the local repo
mkdir test-to-connect
cd test-to-connect
git init
## Add your user name and email to Git.
git config --global user.name "Your name"
git config --global user.email "your-gl-account-email@example.com"
## Create a new private repo after pushing.
git remote set origin https://your-gl-instance-host.dev/your-username/your-new-project-slug
## Commit
git commit -m "Initial commit"
## Push to GitLab
git push origin
## Username for 'https://your-gl-instance-host.dev': your-username
## Password for 'https://your-username@your-gl-instance-host.dev' [REDACTED]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1487 次 |
| 最近记录: |