git - GitLab 设置 ssh 密钥
问题描述
在将 git global 配置为:
$ git config --global user.name "My Username"
$ git config --global user.email "myeamil.com"
$ git clone git@gitlab.com:our-projects/this-project.git
$ cd this-project
$ touch README.md
$ git add README.md
$ git commit -m "add README"
然后按照此处描述的步骤生成并添加一个ssh key
(我实际上创建了一个ED25519 SSH keys
)。但是确保正确添加 ssh 的测试失败了。
$ ssh -T git@our-projects/this-project.git
ssh: Could not resolve hostname gitlab.com:it-porto/transportation-mode-detection.git: Name or service not known
$ ssh -T git@our-projects
ssh: Could not resolve hostname gitlab.com:it-porto/transportation-mode-detection.git: Name or service not known
$ ssh -T git@this-project.git
ssh: Could not resolve hostname gitlab.com:it-porto/transportation-mode-detection.git: Name or service not known
我的 ssh 密钥目录的内容:
$ ls /home/user/.ssh/
id_ed25519 id_ed25519.pub id_rsa id_rsa.pub known_hosts known_hosts.old
我该如何解决?
编辑
我ssh -T git@gitlab.com
按照评论中的建议做了一个,显示了一条欢迎消息,但这似乎不起作用,我无法git push
使用遥控器。
$ssh -T git@gitlab.com
Welcome to GitLab, @user!
$git push origin master
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (8/8), 45.49 KiB | 3.50 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0)
remote: GitLab:
remote: A default branch (e.g. master) does not yet exist for our-projects/this-project
remote: Ask a project Owner or Maintainer to create a default branch:
remote:
remote: https://gitlab.com/our-projects/this-project/-/project_members
remote:
To gitlab.com:our-project/tthis-project.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.com:our-projects/this-project.git'
$ git remote -v
origin git@gitlab.com:our-projects/this-projectt.git (fetch)
origin git@gitlab.com:our-projects/this-projectt.git (push)
解决方案
推荐阅读
- excel - 粘贴为值而不复制名称范围
- c - 在 C 中输出自守数
- haskell - 有没有一种有效的方法来生成给定 Haskell 中的泛型(尤其是带有 monads)类型签名的函数?
- spring - 启动应用程序时如何在没有任何异常的情况下将 FOP 与 Spring Boot 一起使用?
- sql-server - Sequelize JS - 如何处理 Sequelize 不支持的 SQL Server 数据类型
- windows - 适用于 Windows (GCM) 的 Git 凭据管理器不提示输入凭据?
- angular - 如何从角度服务中获取值并将其插入导出的类中?
- python - AttributeError:“函数”对象没有属性“ParseFromString”
- postgresql - Postgres Sql 中的离线路由
- verilog - SystemVerilog 中的随机脉冲生成