62 lines
1.9 KiB
Markdown
62 lines
1.9 KiB
Markdown
要通过 git clone 将 Gitea 仓库 git@218.17.89.43:blade/cloud_coin.git 克隆到本地(Gitea 服务运行在端口 10011),需要使用 SSH 协议并显式指定端口。以下是正确命令和完整步骤:正确克隆命令(必须指定端口 10011):bash
|
||
|
||
git clone ssh://git@218.17.89.43:10011/blade/cloud_coin.git
|
||
|
||
克隆后会在当前目录生成 cloud_coin 文件夹。
|
||
完整操作步骤:1. 确保本地已配置 SSH 密钥bash
|
||
|
||
# 生成密钥(如果还没有)
|
||
ssh-keygen -t ed25519 -C "your_email@example.com"
|
||
|
||
查看公钥:bash
|
||
|
||
cat ~/.ssh/id_ed25519.pub
|
||
|
||
复制全部内容,粘贴到 Gitea 网页的:
|
||
用户头像 → 设置 → SSH / GPG 密钥 → 添加密钥
|
||
|
||
2. 测试 SSH 连接(强烈推荐)bash
|
||
|
||
ssh -T -p 10011 git@218.17.89.43
|
||
|
||
成功会显示:
|
||
|
||
Hi there, You've successfully authenticated...
|
||
|
||
如果提示 Permission denied (publickey),说明密钥未添加或 SSH 服务未启用。
|
||
3. 执行克隆bash
|
||
|
||
git clone ssh://git@218.17.89.43:10011/blade/cloud_coin.git
|
||
|
||
简化后续操作(推荐配置 ~/.ssh/config)编辑 ~/.ssh/config 文件(没有就创建):plaintext
|
||
|
||
Host gitea-cloud
|
||
HostName 218.17.89.43
|
||
User git
|
||
Port 10011
|
||
IdentityFile ~/.ssh/id_ed25519
|
||
|
||
保存后,以后克隆、push、pull 都只需写:bash
|
||
|
||
git clone gitea-cloud:blade/cloud_coin.git
|
||
|
||
非常简洁!常见错误提醒错误写法
|
||
问题
|
||
git clone git@218.17.89.43:blade/cloud_coin.git
|
||
未指定端口,默认连 22,失败
|
||
git clone git@218.17.89.43:10011/blade/cloud_coin.git
|
||
缺少 ssh://,部分系统会报错
|
||
|
||
总结最终推荐命令(一次配置,永久使用):bash
|
||
|
||
# 1. 配置 ~/.ssh/config(如上)
|
||
# 2. 克隆
|
||
git clone gitea-cloud:blade/cloud_coin.git
|
||
|
||
或直接使用完整 URL:bash
|
||
|
||
git clone ssh://git@218.17.89.43:10011/blade/cloud_coin.git
|
||
|
||
克隆成功后,你就可以在本地进行 git pull、git push 等操作了。
|
||
|